feat: add status notes to force delete notifications

- Add notes parameter to force delete interactions to provide more context
- Include company registry status in force delete notifications
- Add status mapping constants for better readability
- Move status note assignment before save in force delete process

Technical details:
- Add notes field to Domains::ForceDelete::Base interaction
- Update force delete notifications to include status notes
- Add REGISTRY_STATUSES mapping in CompanyRegisterStatusJob
- Update tests to verify new notification format
This commit is contained in:
oleghasjanov 2025-01-08 14:50:47 +02:00
parent 45c77f7052
commit 2ec545b3aa
7 changed files with 22 additions and 9 deletions

View file

@ -16,6 +16,9 @@ module Domains
string :email,
default: nil,
description: 'Possible invalid email to notify on'
string :notes,
default: nil,
description: 'Notes to add reason to the force delete'
validates :type, inclusion: { in: %i[fast_track soft] }
end

View file

@ -11,7 +11,8 @@ module Domains
ident: domain.registrant.ident,
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date)
purge_date: domain.purge_date,
notes: notes)
else
I18n.t('force_delete_set_on_domain',
domain_name: domain.name,
@ -30,7 +31,8 @@ module Domains
ident: domain.registrant.ident,
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date)
purge_date: domain.purge_date,
notes: notes)
else
I18n.t('force_delete_auto_email',
domain_name: domain.name,

View file

@ -4,6 +4,7 @@ module Domains
def execute
domain.force_delete_type = type
type == :fast_track ? force_delete_fast_track : force_delete_soft
domain.status_notes[DomainStatus::FORCE_DELETE] = "Company no: #{domain.registrant.ident}" if reason == 'invalid_company'
domain.save(validate: false)
end
@ -12,8 +13,6 @@ module Domains
expire_warning_period_days +
redemption_grace_period_days
domain.force_delete_start = Time.zone.today + 1.day
domain.status_notes[DomainStatus::FORCE_DELETE] = "Company no: #{domain.registrant.ident}" if reason == 'invalid_company'
end
def force_delete_soft

View file

@ -3,6 +3,13 @@ require 'zip'
class CompanyRegisterStatusJob < ApplicationJob
PAYMENT_STATEMENT_BUSINESS_REGISTRY_REASON = 'Kustutamiskanne dokumentide hoidjata'
REGISTRY_STATUSES = {
Contact::REGISTERED => 'registered',
Contact::LIQUIDATED => 'liquidated',
Contact::BANKRUPT => 'bankrupt',
Contact::DELETED => 'deleted'
}
queue_as :default
def perform(days_interval = 14, spam_time_delay = 1, batch_size = 100)
@ -58,7 +65,8 @@ class CompanyRegisterStatusJob < ApplicationJob
type: :fast_track,
notify_by_email: true,
reason: 'invalid_company',
email: contact.email
email: contact.email,
notes: "Contact has status #{REGISTRY_STATUSES[contact.company_register_status]}"
)
end
end

View file

@ -47,9 +47,9 @@ module Domain::ForceDelete
statuses.include?(DomainStatus::FORCE_DELETE)
end
def schedule_force_delete(type: :fast_track, notify_by_email: false, reason: nil, email: nil)
def schedule_force_delete(type: :fast_track, notify_by_email: false, reason: nil, email: nil, notes: nil)
Domains::ForceDelete::SetForceDelete.run(domain: self, type: type, reason: reason,
notify_by_email: notify_by_email, email: email)
notify_by_email: notify_by_email, email: email, notes: notes)
end
def cancel_force_delete

View file

@ -675,7 +675,7 @@ en:
actions: Actions
contact_has_been_archived: 'Contact with code %{contact_code} has been archieved because it has been orphaned for longer than %{orphan_months} months.'
dns_policy_violation: "Data management policy violation: DNSKEY does not match or not found in the authoritative nameservers"
invalid_ident: 'Force delete set on domain %{domain_name}. Outzone date: %{outzone_date}. Purge date: %{purge_date}. Invalid ident %{ident}'
invalid_ident: 'Force delete set on domain %{domain_name}. Outzone date: %{outzone_date}. Purge date: %{purge_date}. Invalid ident %{ident}. %{notes}'
number:
currency:

View file

@ -184,7 +184,8 @@ class CompanyRegisterStatusJobTest < ActiveSupport::TestCase
ident: @registrant_acme.ident,
domain_name: @registrant_acme.registrant_domains.first.name,
outzone_date: @registrant_acme.registrant_domains.first.outzone_date,
purge_date: @registrant_acme.registrant_domains.first.purge_date)
purge_date: @registrant_acme.registrant_domains.first.purge_date,
notes: "Contact has status deleted")
assert_equal @registrant_acme.registrant_domains.first.registrar.notifications.last.text, template
CompanyRegister::Client.define_singleton_method(:new, original_new_method)