From dadb8ba88a6a18c33af2a1479c0805b814a73946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Fri, 4 Sep 2020 11:52:52 +0300 Subject: [PATCH] Send poll message to Registrar after it's contact has been archieved --- app/models/concerns/contact/archivable.rb | 9 ++++++++- config/locales/en.yml | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/contact/archivable.rb b/app/models/concerns/contact/archivable.rb index 8218dedaf..ae9fdf053 100644 --- a/app/models/concerns/contact/archivable.rb +++ b/app/models/concerns/contact/archivable.rb @@ -17,16 +17,23 @@ module Concerns inactive end - def archive(verified: false) + def archive(verified: false, notify: true) unless verified raise 'Contact cannot be archived' unless archivable?(post: true) end + notify_registrar_about_archivation if notify destroy! end private + def notify_registrar_about_archivation + registrar.notifications.create!(text: I18n.t('contact_has_been_archived', + contact_code: code, + orphan_months: Setting.orphans_contacts_in_months)) + end + def inactive? if DomainVersion.contact_unlinked_more_than?(contact_id: id, period: inactivity_period) return true diff --git a/config/locales/en.yml b/config/locales/en.yml index 27299072e..6c9877de4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -643,6 +643,7 @@ en: cant_match_version: 'Impossible match version with request' user_not_authenticated: "user not authenticated" 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.' number: currency: