mirror of
https://github.com/internetee/registry.git
synced 2025-06-05 04:07:33 +02:00
Make sure what expired domain emails will not be sent to non-valid addreses
This commit is contained in:
parent
91093b274d
commit
29f7aa19ac
4 changed files with 33 additions and 18 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
class EmailValidator
|
||||
def self.regexp
|
||||
Devise::email_regexp
|
||||
end
|
||||
|
||||
def initialize(email)
|
||||
@email = email
|
||||
end
|
||||
|
||||
def valid?
|
||||
email =~ self.class.regexp
|
||||
end
|
||||
|
||||
attr_reader :email
|
||||
end
|
|
@ -22,4 +22,29 @@ class DomainExpireMailerTest < ActionMailer::TestCase
|
|||
assert_equal I18n.t("domain_expire_mailer.expired_soft.subject", domain_name: domain.name),
|
||||
email.subject
|
||||
end
|
||||
|
||||
def test_delivers_domain_expiration_soft_email_if_auto_fd
|
||||
domain = domains(:shop)
|
||||
assert_not domain.force_delete_scheduled?
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
email = 'some@strangesentence@internet.ee'
|
||||
|
||||
Truemail.configure.default_validation_type = :regex
|
||||
|
||||
contact = domain.admin_contacts.first
|
||||
contact.update_attribute(:email, email)
|
||||
contact.email_verification.verify
|
||||
|
||||
assert contact.email_verification_failed?
|
||||
|
||||
domain.reload
|
||||
|
||||
assert domain.force_delete_scheduled?
|
||||
|
||||
email = DomainExpireMailer.expired_soft(domain: domain, registrar: domain.registrar).deliver_now
|
||||
|
||||
assert_emails 1
|
||||
assert_equal I18n.t("domain_expire_mailer.expired_soft.subject", domain_name: domain.name),
|
||||
email.subject
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue