mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 09:21:43 +02:00
Merge pull request #2755 from internetee/upgrade-registrar-invalid-company-notification
Refactor force delete notifications and improve status handling
This commit is contained in:
commit
5b1a5a6d06
5 changed files with 26 additions and 12 deletions
|
@ -5,9 +5,19 @@ module Domains
|
|||
email.present? ? notify_with_email : notify_without_email
|
||||
end
|
||||
|
||||
def force_delete_type
|
||||
type == :soft ? 'Soft' : 'Fast Track'
|
||||
end
|
||||
|
||||
def force_delete_start_date
|
||||
domain.force_delete_start.strftime('%d.%m.%Y')
|
||||
end
|
||||
|
||||
def notify_without_email
|
||||
template = if reason == 'invalid_company'
|
||||
I18n.t('invalid_ident',
|
||||
force_delete_type: force_delete_type,
|
||||
force_delete_start_date: force_delete_start_date,
|
||||
ident: domain.registrant.ident,
|
||||
domain_name: domain.name,
|
||||
outzone_date: domain.outzone_date,
|
||||
|
@ -28,6 +38,8 @@ module Domains
|
|||
def notify_with_email
|
||||
template = if reason == 'invalid_company'
|
||||
I18n.t('invalid_ident',
|
||||
force_delete_type: force_delete_type,
|
||||
force_delete_start_date: force_delete_start_date,
|
||||
ident: domain.registrant.ident,
|
||||
domain_name: domain.name,
|
||||
outzone_date: domain.outzone_date,
|
||||
|
|
|
@ -75,18 +75,12 @@ class CompanyRegisterStatusJob < ApplicationJob
|
|||
contact.registrant_domains.each do |domain|
|
||||
next if domain.force_delete_scheduled?
|
||||
|
||||
company_status = if company_status.nil?
|
||||
'Contact not found in EE business registry'
|
||||
else
|
||||
"Contact has status #{REGISTRY_STATUSES[company_status]}"
|
||||
end
|
||||
|
||||
domain.schedule_force_delete(
|
||||
type: :fast_track,
|
||||
notify_by_email: true,
|
||||
reason: 'invalid_company',
|
||||
email: contact.email,
|
||||
notes: company_status
|
||||
notes: company_status_notes(company_status)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -142,15 +136,13 @@ class CompanyRegisterStatusJob < ApplicationJob
|
|||
def soft_delete_company(contact, company_status)
|
||||
contact.registrant_domains.reject { |domain| domain.force_delete_scheduled? }.each do |domain|
|
||||
next if domain.force_delete_scheduled?
|
||||
|
||||
company_status = company_status.nil? ? 'No information' : REGISTRY_STATUSES[company_status]
|
||||
|
||||
domain.schedule_force_delete(
|
||||
type: :soft,
|
||||
notify_by_email: true,
|
||||
reason: 'invalid_company',
|
||||
email: contact.email,
|
||||
notes: "Contact has status #{company_status}")
|
||||
notes: company_status_notes(company_status))
|
||||
end
|
||||
|
||||
puts "Soft delete process initiated for company: #{contact.name} with ID: #{contact.id}"
|
||||
|
@ -168,4 +160,12 @@ class CompanyRegisterStatusJob < ApplicationJob
|
|||
def whitelisted_company?(contact)
|
||||
whitelisted_companies.include?(contact.ident)
|
||||
end
|
||||
|
||||
def company_status_notes(company_status)
|
||||
if company_status.nil?
|
||||
'Contact not found in EE business registry'
|
||||
else
|
||||
"Contact has status #{REGISTRY_STATUSES.fetch(company_status, company_status)}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue