mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 23:24:48 +02:00
Merge remote-tracking branch 'origin/master' into 1763-registrar-bulk-renew
This commit is contained in:
commit
00a65b3b01
40 changed files with 818 additions and 160 deletions
53
app/interactions/domains/delete_confirm/base.rb
Normal file
53
app/interactions/domains/delete_confirm/base.rb
Normal file
|
@ -0,0 +1,53 @@
|
|||
module Domains
|
||||
module DeleteConfirm
|
||||
class Base < ActiveInteraction::Base
|
||||
object :domain,
|
||||
class: Domain,
|
||||
description: 'Domain to confirm release'
|
||||
string :action
|
||||
string :initiator,
|
||||
default: nil
|
||||
|
||||
validates :domain, :action, presence: true
|
||||
validates :action, inclusion: { in: [RegistrantVerification::CONFIRMED,
|
||||
RegistrantVerification::REJECTED] }
|
||||
|
||||
def raise_errors!(domain)
|
||||
return unless domain.errors.any?
|
||||
|
||||
message = "domain #{domain.name} failed with errors #{domain.errors.full_messages}"
|
||||
throw message
|
||||
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
|
17
app/interactions/domains/delete_confirm/process_action.rb
Normal file
17
app/interactions/domains/delete_confirm/process_action.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
module Domains
|
||||
module DeleteConfirm
|
||||
class ProcessAction < Base
|
||||
def execute
|
||||
::PaperTrail.request.whodunnit = "interaction - #{self.class.name} - #{action} by"\
|
||||
" #{initiator}"
|
||||
|
||||
case action
|
||||
when RegistrantVerification::CONFIRMED
|
||||
compose(ProcessDeleteConfirmed, inputs)
|
||||
when RegistrantVerification::REJECTED
|
||||
compose(ProcessDeleteRejected, inputs)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,50 @@
|
|||
module Domains
|
||||
module DeleteConfirm
|
||||
class ProcessDeleteConfirmed < Base
|
||||
def execute
|
||||
notify_registrar(:poll_pending_delete_confirmed_by_registrant)
|
||||
domain.apply_pending_delete!
|
||||
raise_errors!(domain)
|
||||
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
|
|
@ -0,0 +1,32 @@
|
|||
module Domains
|
||||
module DeleteConfirm
|
||||
class ProcessDeleteRejected < Base
|
||||
def execute
|
||||
domain.cancel_pending_delete
|
||||
notify_registrar(:poll_pending_delete_rejected_by_registrant)
|
||||
domain.save(validate: false)
|
||||
raise_errors!(domain)
|
||||
|
||||
send_domain_delete_rejected_email
|
||||
end
|
||||
|
||||
def send_domain_delete_rejected_email
|
||||
if domain.registrant_verification_token.blank?
|
||||
warn "EMAIL NOT DELIVERED: registrant_verification_token is missing for #{domain.name}"
|
||||
elsif domain.registrant_verification_asked_at.blank?
|
||||
warn "EMAIL NOT DELIVERED: registrant_verification_asked_at is missing for #{domain.name}"
|
||||
else
|
||||
send_email
|
||||
end
|
||||
end
|
||||
|
||||
def warn(message)
|
||||
Rails.logger.warn(message)
|
||||
end
|
||||
|
||||
def send_email
|
||||
DomainDeleteMailer.rejected(domain).deliver_now
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
module Domains
|
||||
module DeleteConfirm
|
||||
module DeleteConfirmEmail
|
||||
class SendRequest < ActiveInteraction::Base
|
||||
object :domain,
|
||||
class: Domain,
|
Loading…
Add table
Add a link
Reference in a new issue