Implement FD notes updating

This commit is contained in:
dinsmol 2022-01-14 00:39:31 +03:00
parent f461388783
commit c47b093a45
6 changed files with 83 additions and 2 deletions

View file

@ -84,6 +84,7 @@ module Actions
return false if @error
contact.generate_code
contact.email_history = contact.email
contact.save
end
end

View file

@ -112,6 +112,7 @@ module Actions
email_changed = contact.will_save_change_to_email?
old_email = contact.email_was
contact.email_history = old_email
updated = contact.save
if updated && email_changed && contact.registrant?

View file

@ -5,7 +5,8 @@ module Depp
attr_accessor :id, :name, :email, :phone, :org_name,
:ident, :ident_type, :ident_country_code,
:street, :city, :zip, :state, :country_code,
:password, :legal_document, :statuses, :code
:password, :legal_document, :statuses, :code,
:email_history
DISABLED = 'Disabled'
DISCLOSURE_TYPES = [DISABLED, '1', '0']

View file

@ -62,6 +62,7 @@ class ValidationEvent < ApplicationRecord
if object.need_to_start_force_delete?
start_force_delete
elsif object.need_to_lift_force_delete?
refresh_status_notes
lift_force_delete
end
end
@ -70,6 +71,23 @@ class ValidationEvent < ApplicationRecord
Domains::ForceDeleteEmail::Base.run(email: email)
end
def refresh_status_notes
old_email = object.email_history
domain_contacts = Contact.where(email: email).map(&:domain_contacts).flatten
registrant_ids = Registrant.where(email: email).pluck(:id)
domains = domain_contacts.map(&:domain).flatten +
Domain.where(registrant_id: registrant_ids)
domains.uniq.each do |domain|
next unless domain.status_notes[DomainStatus::FORCE_DELETE]
domain.status_notes[DomainStatus::FORCE_DELETE].slice!(old_email)
domain.status_notes[DomainStatus::FORCE_DELETE].lstrip!
domain.save(validate: false)
end
end
def lift_force_delete
# domain_contacts = Contact.where(email: email).map(&:domain_contacts).flatten
# registrant_ids = Registrant.where(email: email).pluck(:id)