From b28748d667c76ef73e69ae69f2a303d4c195a49d Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 12 Jan 2016 14:06:32 +0200 Subject: [PATCH 1/3] Story#111503520 - couldn't apply pending update as registrar wasn't valid --- app/jobs/domain_update_confirm_job.rb | 7 ++----- app/models/epp/domain.rb | 13 ++++++------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index be0ada219..3da95287d 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -3,19 +3,16 @@ class DomainUpdateConfirmJob < 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) + domain.is_admin = true case action when RegistrantVerification::CONFIRMED domain.poll_message!(:poll_pending_update_confirmed_by_registrant) - domain.apply_pending_update! do |e| - e.instance_variable_set("@changed_attributes", e.changed_attributes.merge("statuses"=>[])) - end + domain.apply_pending_update! domain.clean_pendings! - WhoisRecord.find_by(domain_id: domain.id).save when RegistrantVerification::REJECTED domain.send_mail :pending_update_rejected_notification_for_new_registrant domain.poll_message!(:poll_pending_update_rejected_by_registrant) domain.clean_pendings! - domain.instance_variable_set("@changed_attributes", domain.changed_attributes.merge("statuses"=>[])) domain.save end destroy # it's best to destroy the job in the same transaction diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index d84de4ca6..15e16163a 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -507,18 +507,17 @@ class Epp::Domain < Domain frame = Nokogiri::XML(pending_json['frame']) self.deliver_emails = true # turn on email delivery - send_mail :registrant_updated_notification_for_old_registrant - - statuses.delete(DomainStatus::PENDING_UPDATE) - yield(self) if block_given? # need to skip statuses check here - self.save - + self.statuses.delete(DomainStatus::PENDING_UPDATE) ::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user + + send_mail :registrant_updated_notification_for_old_registrant return unless update(frame, user, false) clean_pendings! send_mail :registrant_updated_notification_for_new_registrant - update_whois_record + WhoisRecord.find_by(domain_id: id).save # need to reload model + + save! # for notification if everything fails true end From 782fcc9deccb5d389e23c4f67a98e58b8fbe0c84 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 12 Jan 2016 17:29:13 +0200 Subject: [PATCH 2/3] Story#111503520 - reject verification shouldn't validate --- app/jobs/domain_update_confirm_job.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index 3da95287d..f028b95f8 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -13,7 +13,7 @@ class DomainUpdateConfirmJob < Que::Job domain.send_mail :pending_update_rejected_notification_for_new_registrant domain.poll_message!(:poll_pending_update_rejected_by_registrant) domain.clean_pendings! - domain.save + domain.save(validate: false) end destroy # it's best to destroy the job in the same transaction end From d9d8aef813fdc99a529086da899a430d6af4e202 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 12 Jan 2016 18:27:29 +0200 Subject: [PATCH 3/3] Story#111503520 - custom lowlevel pending state rejection --- app/jobs/domain_update_confirm_job.rb | 3 +-- app/models/domain.rb | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index f028b95f8..098b9853e 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -12,8 +12,7 @@ class DomainUpdateConfirmJob < Que::Job when RegistrantVerification::REJECTED domain.send_mail :pending_update_rejected_notification_for_new_registrant domain.poll_message!(:poll_pending_update_rejected_by_registrant) - domain.clean_pendings! - domain.save(validate: false) + domain.clean_pendings_lowlevel end destroy # it's best to destroy the job in the same transaction end diff --git a/app/models/domain.rb b/app/models/domain.rb index 05ffafc4d..baf7d0308 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -244,7 +244,7 @@ class Domain < ActiveRecord::Base if domain.pending_delete? || domain.pending_delete_confirmation? DomainMailer.pending_delete_expired_notification(domain.id, true).deliver end - domain.clean_pendings! + domain.clean_pendings_lowlevel unless Rails.env.test? STDOUT << "#{Time.zone.now.utc} Domain.clean_expired_pendings: ##{domain.id} (#{domain.name})\n" end @@ -439,6 +439,25 @@ class Domain < ActiveRecord::Base save end + + # state change shouln't be + def clean_pendings_lowlevel + statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION) + statuses.delete(DomainStatus::PENDING_UPDATE) + statuses.delete(DomainStatus::PENDING_DELETE) + + status_notes[DomainStatus::PENDING_UPDATE] = '' + status_notes[DomainStatus::PENDING_DELETE] = '' + + update_columns( + registrant_verification_token: nil, + registrant_verification_asked_at: nil, + pending_json: {}, + status_notes: status_notes, + statuses: statuses.presence || [DomainStatus::OK] + ) + end + def pending_update! return true if pending_update? self.epp_pending_update = true # for epp