diff --git a/app/jobs/domain_delete_confirm_job.rb b/app/jobs/domain_delete_confirm_job.rb index cce230234..e147e3aa8 100644 --- a/app/jobs/domain_delete_confirm_job.rb +++ b/app/jobs/domain_delete_confirm_job.rb @@ -3,17 +3,30 @@ class DomainDeleteConfirmJob < Que::Job # it's recommended to keep transaction against job table as short as possible. ActiveRecord::Base.transaction do domain = Epp::Domain.find(domain_id) + case action when RegistrantVerification::CONFIRMED domain.poll_message!(:poll_pending_delete_confirmed_by_registrant) domain.apply_pending_delete! + raise_errors!(domain) + when RegistrantVerification::REJECTED - DomainMailer.pending_delete_rejected_notification(domain_id, true).deliver domain.statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION) domain.poll_message!(:poll_pending_delete_rejected_by_registrant) + domain.cancel_pending_delete + domain.save(validate: false) + raise_errors!(domain) + + DomainMailer.pending_delete_rejected_notification(domain_id, true).deliver end + destroy # it's best to destroy the job in the same transaction end end + + + def raise_errors!(domain) + throw "domain #{domain.name} failed with errors #{domain.errors.full_messages}" if domain.errors.any? + end end