mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 03:06:14 +02:00
Add data migration to fill EmailAddressVerifications
This commit is contained in:
parent
9758c82221
commit
ee7d69c1ce
4 changed files with 29 additions and 160 deletions
|
@ -3,12 +3,14 @@ module Concerns
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
def email_verification
|
||||
EmailAddressVerification.find_or_create_by(email: self.email)
|
||||
EmailAddressVerification.find_or_create_by(email: self.email,
|
||||
domain: Mail::Address.new(self.email).domain)
|
||||
end
|
||||
|
||||
def billing_email_verification
|
||||
if self.attribute_names.include?('billing_email')
|
||||
EmailAddressVerification.find_or_create_by(email: self.billing_email)
|
||||
EmailAddressVerification.find_or_create_by(email: self.billing_email,
|
||||
domain: Mail::Address.new(self.email).domain)
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
@ -23,8 +25,6 @@ module Concerns
|
|||
end
|
||||
|
||||
def correct_billing_email_format
|
||||
return if self[:billing_email].blank?
|
||||
|
||||
verify_email_mx_smtp(field: :billing_email, email: billing_email)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,6 +10,11 @@ class EmailAddressVerification < ApplicationRecord
|
|||
def verify
|
||||
validation_request = Truemail.validate(email)
|
||||
|
||||
update(verified_at: Time.zone.now) if validation_request.result.success
|
||||
if validation_request.result.success
|
||||
update(verified_at: Time.zone.now,
|
||||
success: true)
|
||||
end
|
||||
|
||||
validation_request.result.success
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue