From 6f8a8f6435f6e8459ab07ebec7f38548ccc9bb74 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 20 Jan 2020 13:50:38 +0500 Subject: [PATCH] Add tech contacts & info & name@name to force delete mailer See #1477 --- app/mailers/domain_delete_mailer.rb | 2 +- app/models/domain.rb | 9 +++++++++ test/mailers/domain_delete_mailer_test.rb | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/mailers/domain_delete_mailer.rb b/app/mailers/domain_delete_mailer.rb index f1a7fc237..1f08204bf 100644 --- a/app/mailers/domain_delete_mailer.rb +++ b/app/mailers/domain_delete_mailer.rb @@ -44,7 +44,7 @@ class DomainDeleteMailer < ApplicationMailer subject = default_i18n_subject(domain_name: domain.name) mail(from: forced_email_from, - to: domain.primary_contact_emails, + to: domain.force_delete_contact_emails, subject: subject, template_path: 'mailers/domain_delete_mailer/forced', template_name: template_name) diff --git a/app/models/domain.rb b/app/models/domain.rb index 734243c0d..ca2a664b0 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -587,6 +587,15 @@ class Domain < ApplicationRecord (admin_contacts.emails + [registrant.email]).uniq end + def force_delete_contact_emails + (primary_contact_emails + tech_contacts.pluck(:email) + + ["info@#{name}", "#{prepared_domain_name}@#{name}"]).uniq + end + + def prepared_domain_name + name.split('.')&.first + end + def new_registrant_email pending_json['new_registrant_email'] end diff --git a/test/mailers/domain_delete_mailer_test.rb b/test/mailers/domain_delete_mailer_test.rb index e6a39ff3d..ae060921f 100644 --- a/test/mailers/domain_delete_mailer_test.rb +++ b/test/mailers/domain_delete_mailer_test.rb @@ -73,9 +73,9 @@ class DomainDeleteMailerTest < ActionMailer::TestCase assert_emails 1 assert_equal ['legal@registry.test'], email.from - assert_equal %w[jane@mail.test john@inbox.test], email.to + assert_equal @domain.force_delete_contact_emails, email.to assert_equal 'Domeen shop.test on kustutusmenetluses' \ ' / Domain shop.test is in deletion process' \ ' / Домен shop.test в процессе удаления', email.subject end -end \ No newline at end of file +end