feat: enhance soft delete process for invalid companies

- Add email notification for soft delete process
- Include company status information in force delete notes
- Add validation check to prevent duplicate force delete scheduling
- Pass additional context (reason, email) to force delete process

This improves the soft delete process by providing more detailed
information about why the domain is being force deleted and ensures
proper notification to the contact.
This commit is contained in:
oleghasjanov 2025-01-09 10:48:06 +02:00
parent 2ec545b3aa
commit 8a93a8b4d2

View file

@ -111,7 +111,14 @@ class CompanyRegisterStatusJob < ApplicationJob
def soft_delete_company(contact) def soft_delete_company(contact)
contact.registrant_domains.reject { |domain| domain.force_delete_scheduled? }.each do |domain| contact.registrant_domains.reject { |domain| domain.force_delete_scheduled? }.each do |domain|
domain.schedule_force_delete(type: :soft) next if domain.force_delete_scheduled?
domain.schedule_force_delete(
type: :soft,
notify_by_email: true,
reason: 'invalid_company',
email: contact.email,
notes: "Contact has status #{REGISTRY_STATUSES[contact.company_register_status]}")
end end
puts "Soft delete process initiated for company: #{contact.name} with ID: #{contact.id}" puts "Soft delete process initiated for company: #{contact.name} with ID: #{contact.id}"