mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 00:33:36 +02:00
Story #108621138 - add a registrar message for deleteCandidate was deleted
This commit is contained in:
parent
8939078072
commit
a0ff1c99d0
3 changed files with 29 additions and 3 deletions
|
@ -11,7 +11,19 @@ class Epp::PollsController < EppController
|
|||
|
||||
render_epp_response 'epp/poll/poll_no_messages' and return unless @message
|
||||
if @message.attached_obj_type && @message.attached_obj_id
|
||||
@object = Object.const_get(@message.attached_obj_type).find(@message.attached_obj_id)
|
||||
begin
|
||||
@object = Object.const_get(@message.attached_obj_type).find(@message.attached_obj_id)
|
||||
rescue => problem
|
||||
# the data model might be inconsistent; or ...
|
||||
# this could happen if the registrar does not dequeue messages, and then the domain was deleted
|
||||
|
||||
# SELECT messages.id, domains.name, messages.body FROM messages LEFT OUTER
|
||||
# JOIN domains ON attached_obj_id::INTEGER = domains.id
|
||||
# WHERE attached_obj_type = 'Epp::Domain' AND name IS NULL;
|
||||
|
||||
Rails.logger.error 'orphan message, error ignored: ' + problem.to_s
|
||||
# now we should dequeue or delete the messages avoid duplicate log alarms
|
||||
end
|
||||
end
|
||||
|
||||
if @message.attached_obj_type == 'Keyrelay'
|
||||
|
|
|
@ -307,14 +307,15 @@ class Domain < ActiveRecord::Base
|
|||
c = 0
|
||||
Domain.where("statuses @> '{deleteCandidate}'::varchar[]").each do |x|
|
||||
Whois::Record.where('domain_id = ?', x.id).try(':destroy')
|
||||
x.destroy
|
||||
destroy_with_message x
|
||||
STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by deleteCandidate ##{x.id} (#{x.name})\n" unless Rails.env.test?
|
||||
|
||||
c += 1
|
||||
end
|
||||
|
||||
Domain.where('force_delete_at <= ?', Time.zone.now).each do |x|
|
||||
Whois::Record.where('domain_id = ?', x.id).try(':destroy')
|
||||
x.destroy
|
||||
destroy_with_message x
|
||||
STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by force delete time ##{x.id} (#{x.name})\n" unless Rails.env.test?
|
||||
c += 1
|
||||
end
|
||||
|
@ -324,6 +325,15 @@ class Domain < ActiveRecord::Base
|
|||
# rubocop: enable Metrics/AbcSize
|
||||
# rubocop:enable Rails/FindEach
|
||||
# rubocop: enable Metrics/LineLength
|
||||
def destroy_with_message(domain)
|
||||
domain.destroy
|
||||
bye_bye = domain.versions.last
|
||||
domain.registrar.messages.create!(
|
||||
body: I18n.t(:domain_deleted),
|
||||
attached_obj_id: bye_bye.id,
|
||||
attached_obj_type: bye_bye.class.to_s # DomainVersion
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def name=(value)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
builder.tag!('domain:delData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do
|
||||
builder.tag!('domain:name', bye_bye.object['name'])
|
||||
builder.tag!('domain:exDate', bye_bye.created_at)
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue