mirror of
https://github.com/internetee/registry.git
synced 2025-06-13 08:04:45 +02:00
Move confirmed delete procedures to interactor
This commit is contained in:
parent
f6a7a08b24
commit
5a059e86bb
3 changed files with 72 additions and 3 deletions
|
@ -18,6 +18,36 @@ module Domains
|
||||||
message = "domain #{domain.name} failed with errors #{domain.errors.full_messages}"
|
message = "domain #{domain.name} failed with errors #{domain.errors.full_messages}"
|
||||||
throw message
|
throw message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def notify_registrar(message_key)
|
||||||
|
domain.registrar.notifications.create!(
|
||||||
|
text: "#{I18n.t(message_key)}: #{domain.name}",
|
||||||
|
attached_obj_id: domain.id,
|
||||||
|
attached_obj_type: domain.class.to_s
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def preclean_pendings
|
||||||
|
domain.registrant_verification_token = nil
|
||||||
|
domain.registrant_verification_asked_at = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def clean_pendings!
|
||||||
|
domain.is_admin = true
|
||||||
|
domain.registrant_verification_token = nil
|
||||||
|
domain.registrant_verification_asked_at = nil
|
||||||
|
domain.pending_json = {}
|
||||||
|
clear_statuses
|
||||||
|
domain.save
|
||||||
|
end
|
||||||
|
|
||||||
|
def clear_statuses
|
||||||
|
domain.statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION)
|
||||||
|
domain.statuses.delete(DomainStatus::PENDING_UPDATE)
|
||||||
|
domain.statuses.delete(DomainStatus::PENDING_DELETE)
|
||||||
|
domain.status_notes[DomainStatus::PENDING_UPDATE] = ''
|
||||||
|
domain.status_notes[DomainStatus::PENDING_DELETE] = ''
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,10 +2,49 @@ module Domains
|
||||||
module DeleteConfirm
|
module DeleteConfirm
|
||||||
class ProcessDeleteConfirmed < Base
|
class ProcessDeleteConfirmed < Base
|
||||||
def execute
|
def execute
|
||||||
domain.notify_registrar(:poll_pending_delete_confirmed_by_registrant)
|
notify_registrar(:poll_pending_delete_confirmed_by_registrant)
|
||||||
domain.apply_pending_delete!
|
domain.apply_pending_delete!
|
||||||
raise_errors!(domain)
|
raise_errors!(domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def apply_pending_delete!
|
||||||
|
preclean_pendings
|
||||||
|
clean_pendings!
|
||||||
|
DomainDeleteMailer.accepted(domain).deliver_now
|
||||||
|
domain.set_pending_delete!
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_pending_delete!
|
||||||
|
unless domain.pending_deletable?
|
||||||
|
add_epp_error
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
domain.delete_date = delete_date
|
||||||
|
domain.statuses << DomainStatus::PENDING_DELETE
|
||||||
|
set_server_hold if server_holdable?
|
||||||
|
domain.save(validate: false)
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_server_hold
|
||||||
|
domain.statuses << DomainStatus::SERVER_HOLD
|
||||||
|
domain.outzone_at = Time.current
|
||||||
|
end
|
||||||
|
|
||||||
|
def server_holdable?
|
||||||
|
return false if domain.statuses.include?(DomainStatus::SERVER_HOLD)
|
||||||
|
return false if domain.statuses.include?(DomainStatus::SERVER_MANUAL_INZONE)
|
||||||
|
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete_date
|
||||||
|
Time.zone.today + Setting.redemption_grace_period.days + 1.day
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_epp_error
|
||||||
|
domain.add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,10 +9,10 @@ module Domains
|
||||||
domain.save(validate: false)
|
domain.save(validate: false)
|
||||||
raise_errors!(domain)
|
raise_errors!(domain)
|
||||||
|
|
||||||
send_domain_deleted_email
|
send_domain_delete_rejected_email
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_domain_deleted_email
|
def send_domain_delete_rejected_email
|
||||||
if domain.registrant_verification_token.blank?
|
if domain.registrant_verification_token.blank?
|
||||||
warn "EMAIL NOT DELIVERED: registrant_verification_token is missing for #{domain.name}"
|
warn "EMAIL NOT DELIVERED: registrant_verification_token is missing for #{domain.name}"
|
||||||
elsif domain.registrant_verification_asked_at.blank?
|
elsif domain.registrant_verification_asked_at.blank?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue