diff --git a/app/interactions/actions/contact_update.rb b/app/interactions/actions/contact_update.rb index 6831c449b..dc9ebd944 100644 --- a/app/interactions/actions/contact_update.rb +++ b/app/interactions/actions/contact_update.rb @@ -24,6 +24,7 @@ module Actions def maybe_change_email return if Rails.env.test? + return if contact.email == new_attributes[:email] %i[regex mx].each do |m| result = Actions::SimpleMailValidator.run(email: @new_attributes[:email], level: m) @@ -71,6 +72,10 @@ module Actions end def maybe_update_ident + return if contact.identifier.code == ident[:ident] && + contact.identifier.type == ident[:ident_type] && + contact.identifier.country_code == ident[:ident_country_code] + unless ident.is_a?(Hash) contact.add_epp_error('2308', nil, nil, I18n.t('epp.contacts.errors.valid_ident')) @error = true diff --git a/app/models/concerns/email_verifable.rb b/app/models/concerns/email_verifable.rb index d9237df48..05434e658 100644 --- a/app/models/concerns/email_verifable.rb +++ b/app/models/concerns/email_verifable.rb @@ -14,10 +14,20 @@ module EmailVerifable domain_with_fd = domains.select(&:force_delete_scheduled?) domain_with_fd.each do |domain| - contact_emails_valid?(domain) ? domain.cancel_force_delete : nil + cancel_force_delete_if_domain_attributes_are_valid?(domain) end end + def cancel_force_delete_if_domain_attributes_are_valid?(domain) + domain.cancel_force_delete if contact_emails_valid?(domain) && !is_domain_has_invalid_org_contact?(domain) + end + + def is_domain_has_invalid_org_contact?(domain) + return unless domain.force_delete_scheduled? + + domain.status_notes.any? { |note| note.include?("Company no: #{domain.registrant.identifier.code}") } + end + def contact_emails_valid?(domain) domain.contacts.each do |c| return false unless c.need_to_lift_force_delete?