Make sure what expired domain emails will not be sent to non-valid addreses

This commit is contained in:
Alex Sherman 2021-03-22 15:21:53 +05:00
parent 91093b274d
commit 29f7aa19ac
4 changed files with 33 additions and 18 deletions

View file

@ -43,8 +43,11 @@ class DomainExpireMailer < ApplicationMailer
# Needed because there are invalid emails in the database, which have been imported from legacy app
def filter_invalid_emails(emails:, domain:)
emails.select do |email|
valid = EmailValidator.new(email).valid?
old_validation_type = Truemail.configure.default_validation_type
Truemail.configure.default_validation_type = :regex
results = emails.select do |email|
valid = Truemail.valid?(email)
unless valid
logger.info("Unable to send DomainExpireMailer#expired email for domain #{domain.name} (##{domain.id})" \
@ -53,5 +56,7 @@ class DomainExpireMailer < ApplicationMailer
valid
end
Truemail.configure.default_validation_type = old_validation_type
results
end
end

View file

@ -1,5 +1,5 @@
class DomainPresenter
delegate :name, :transfer_code, :registrant, :registrant_id, to: :domain
delegate :name, :transfer_code, :registrant, :registrant_id, :id, to: :domain
def initialize(domain:, view:)
@domain = domain