diff --git a/app/interactions/domains/force_delete/base.rb b/app/interactions/domains/force_delete/base.rb index 712d0c08e..31093c839 100644 --- a/app/interactions/domains/force_delete/base.rb +++ b/app/interactions/domains/force_delete/base.rb @@ -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 diff --git a/app/interactions/domains/force_delete/notify_registrar.rb b/app/interactions/domains/force_delete/notify_registrar.rb index 279fac584..2e209a4c3 100644 --- a/app/interactions/domains/force_delete/notify_registrar.rb +++ b/app/interactions/domains/force_delete/notify_registrar.rb @@ -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, diff --git a/app/interactions/domains/force_delete/set_status.rb b/app/interactions/domains/force_delete/set_status.rb index 770903d5a..cefaf820b 100644 --- a/app/interactions/domains/force_delete/set_status.rb +++ b/app/interactions/domains/force_delete/set_status.rb @@ -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 diff --git a/app/jobs/company_register_status_job.rb b/app/jobs/company_register_status_job.rb index f3b9dc01e..8f1120f4f 100644 --- a/app/jobs/company_register_status_job.rb +++ b/app/jobs/company_register_status_job.rb @@ -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 diff --git a/app/models/concerns/domain/force_delete.rb b/app/models/concerns/domain/force_delete.rb index e0f98ea84..6a7949fef 100644 --- a/app/models/concerns/domain/force_delete.rb +++ b/app/models/concerns/domain/force_delete.rb @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index 2f9ba4b15..15c0f4419 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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: diff --git a/test/jobs/company_register_status_job_test.rb b/test/jobs/company_register_status_job_test.rb index aff3785f9..775acf567 100644 --- a/test/jobs/company_register_status_job_test.rb +++ b/test/jobs/company_register_status_job_test.rb @@ -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)