Merge pull request #1735 from internetee/1178-invalid-email-fd-template

Add invalid email template to ForceDelete notifications
This commit is contained in:
Timo Võhmar 2020-11-06 16:06:09 +02:00 committed by GitHub
commit 5e6fb351ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 148 additions and 40 deletions

View file

@ -20,7 +20,13 @@ module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
end
def notification_template
registrant.org? ? 'legal_person' : 'private_person'
if contact_emails_verification_failed.present?
'invalid_email'
elsif registrant.org?
'legal_person'
else
'private_person'
end
end
def force_delete_scheduled?

View file

@ -15,6 +15,10 @@ module Concerns
domain: domain(billing_email))
end
def email_verification_failed?
email_verification&.failed?
end
class_methods do
def domain(email)
Mail::Address.new(email).domain&.downcase || 'not_found'

View file

@ -642,6 +642,10 @@ class Domain < ApplicationRecord
DNS::DomainName.new(name)
end
def contact_emails_verification_failed
contacts.select(&:email_verification_failed?)&.map(&:email)&.uniq
end
def self.to_csv
CSV.generate do |csv|
csv << column_names