From 8a93a8b4d2aaa71685279b6ddaa30e152b44b5b0 Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Thu, 9 Jan 2025 10:48:06 +0200 Subject: [PATCH] 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. --- app/jobs/company_register_status_job.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/jobs/company_register_status_job.rb b/app/jobs/company_register_status_job.rb index 8f1120f4f..dc40d2d8b 100644 --- a/app/jobs/company_register_status_job.rb +++ b/app/jobs/company_register_status_job.rb @@ -111,7 +111,14 @@ class CompanyRegisterStatusJob < ApplicationJob def soft_delete_company(contact) 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 puts "Soft delete process initiated for company: #{contact.name} with ID: #{contact.id}"