mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 01:36:02 +02:00
Merge pull request #1914 from internetee/1837-invalidate-emails-with-bounces
Add check for bounce presence in #failed? method of verification
This commit is contained in:
commit
fb1045a97e
2 changed files with 14 additions and 1 deletions
|
@ -34,13 +34,17 @@ class EmailAddressVerification < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def failed?
|
def failed?
|
||||||
verified_at.present? && !success
|
bounce_present? || (verified_at.present? && !success)
|
||||||
end
|
end
|
||||||
|
|
||||||
def verified?
|
def verified?
|
||||||
success
|
success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def bounce_present?
|
||||||
|
BouncedMailAddress.find_by(email: email).present?
|
||||||
|
end
|
||||||
|
|
||||||
def check_force_delete
|
def check_force_delete
|
||||||
return unless failed?
|
return unless failed?
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,15 @@ class BouncedMailAddressTest < ActiveSupport::TestCase
|
||||||
assert_equal 'smtp; 550 5.1.1 user unknown', bounced_mail.diagnostic
|
assert_equal 'smtp; 550 5.1.1 user unknown', bounced_mail.diagnostic
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_email_with_bounce_considered_nonverified
|
||||||
|
BouncedMailAddress.record(sns_bounce_payload)
|
||||||
|
bounced_mail = BouncedMailAddress.last
|
||||||
|
registrant = domains(:shop).registrant
|
||||||
|
|
||||||
|
assert_equal registrant.email, bounced_mail.email
|
||||||
|
assert registrant.email_verification.failed?
|
||||||
|
end
|
||||||
|
|
||||||
def sns_bounce_payload
|
def sns_bounce_payload
|
||||||
{
|
{
|
||||||
"notificationType": "Bounce",
|
"notificationType": "Bounce",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue