Merge pull request #2271 from internetee/2216-update-fd-notes

Update FD notes when basis of the FD is changed
This commit is contained in:
Timo Võhmar 2022-02-23 17:17:58 +02:00 committed by GitHub
commit c232e8ade6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 139 additions and 143 deletions

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,33 @@ class ValidationEvent < ApplicationRecord
Domains::ForceDeleteEmail::Base.run(email: email)
end
def refresh_status_notes
domain_list.each do |domain|
next unless domain.status_notes[DomainStatus::FORCE_DELETE]
domain.status_notes[DomainStatus::FORCE_DELETE].slice!(object.email_history)
domain.status_notes[DomainStatus::FORCE_DELETE].lstrip!
domain.save(validate: false)
notify_registrar(domain) unless domain.status_notes[DomainStatus::FORCE_DELETE].empty?
end
end
def domain_list
domain_contacts = Contact.where(email: email).map(&:domain_contacts).flatten
registrant_ids = Registrant.where(email: email).pluck(:id)
(domain_contacts.map(&:domain).flatten + Domain.where(registrant_id: registrant_ids)).uniq
end
def notify_registrar(domain)
domain.registrar.notifications.create!(text: I18n.t('force_delete_auto_email',
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date,
email: domain.status_notes[DomainStatus::FORCE_DELETE]))
end
def lift_force_delete
# domain_contacts = Contact.where(email: email).map(&:domain_contacts).flatten
# registrant_ids = Registrant.where(email: email).pluck(:id)