mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 01:36:02 +02:00
Add forceDelete on email_verification failed
This commit is contained in:
parent
4522e4427e
commit
a8e3d67556
4 changed files with 14 additions and 7 deletions
|
@ -1,15 +1,15 @@
|
||||||
module Domains
|
module Domains
|
||||||
module ForceDeleteBounce
|
module ForceDeleteEmail
|
||||||
class Base < ActiveInteraction::Base
|
class Base < ActiveInteraction::Base
|
||||||
object :bounced_mail_address,
|
string :email,
|
||||||
class: BouncedMailAddress,
|
|
||||||
description: 'Bounced email to set ForceDelete from'
|
description: 'Bounced email to set ForceDelete from'
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
email = bounced_mail_address.email
|
|
||||||
domain_contacts = Contact.where(email: email).map(&:domain_contacts).flatten
|
domain_contacts = Contact.where(email: email).map(&:domain_contacts).flatten
|
||||||
domains = domain_contacts.map(&:domain).flatten
|
domains = domain_contacts.map(&:domain).flatten
|
||||||
domains.each do |domain|
|
domains.each do |domain|
|
||||||
|
next if domain.force_delete_scheduled?
|
||||||
|
|
||||||
domain.schedule_force_delete(type: :soft,
|
domain.schedule_force_delete(type: :soft,
|
||||||
notify_by_email: true, reason: 'invalid_email')
|
notify_by_email: true, reason: 'invalid_email')
|
||||||
end
|
end
|
|
@ -45,6 +45,6 @@ class BouncedMailAddress < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def force_delete_from_bounce
|
def force_delete_from_bounce
|
||||||
Domains::ForceDeleteBounce::Base.run(bounced_mail_address: self)
|
Domains::ForceDeleteEmail::Base.run(email: email)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
class EmailAddressVerification < ApplicationRecord
|
class EmailAddressVerification < ApplicationRecord
|
||||||
RECENTLY_VERIFIED_PERIOD = 1.month
|
RECENTLY_VERIFIED_PERIOD = 1.month
|
||||||
|
after_save :check_force_delete
|
||||||
|
|
||||||
scope :not_verified_recently, lambda {
|
scope :not_verified_recently, lambda {
|
||||||
where('verified_at IS NULL or verified_at < ?', verification_period)
|
where('verified_at IS NULL or verified_at < ?', verification_period)
|
||||||
|
@ -40,6 +41,12 @@ class EmailAddressVerification < ApplicationRecord
|
||||||
success
|
success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_force_delete
|
||||||
|
return unless failed?
|
||||||
|
|
||||||
|
Domains::ForceDeleteEmail::Base.run(email: email)
|
||||||
|
end
|
||||||
|
|
||||||
def verify
|
def verify
|
||||||
validation_request = Truemail.validate(email)
|
validation_request = Truemail.validate(email)
|
||||||
|
|
||||||
|
|
|
@ -344,10 +344,10 @@ class ForceDeleteTest < ActionMailer::TestCase
|
||||||
Truemail.configure.default_validation_type = :regex
|
Truemail.configure.default_validation_type = :regex
|
||||||
|
|
||||||
contact = @domain.admin_contacts.first
|
contact = @domain.admin_contacts.first
|
||||||
contact.update(email: 'some@strangesentence@internet.ee')
|
contact.update_attribute(:email, 'some@strangesentence@internet.ee')
|
||||||
|
contact.email_verification.verify
|
||||||
|
|
||||||
assert contact.email_verification_failed?
|
assert contact.email_verification_failed?
|
||||||
assert contact.invalid?
|
|
||||||
|
|
||||||
@domain.reload
|
@domain.reload
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue