mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 05:05:45 +02:00
Add prototype of FD lifting interaction
This commit is contained in:
parent
90cb154d15
commit
6383dede4b
2 changed files with 36 additions and 3 deletions
31
app/interactions/domains/force_delete_lift/base.rb
Normal file
31
app/interactions/domains/force_delete_lift/base.rb
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
module Domains
|
||||||
|
module ForceDeleteLift
|
||||||
|
class Base < ActiveInteraction::Base
|
||||||
|
string :email,
|
||||||
|
description: 'Email to check if ForceDelete needs to be lifted'
|
||||||
|
|
||||||
|
def execute
|
||||||
|
domain_contacts = Contact.where(email: email).map(&:domain_contacts).flatten
|
||||||
|
registrant_ids = Registrant.where(email: email).pluck(:id)
|
||||||
|
|
||||||
|
domains = domain_contacts.map(&:domain).flatten +
|
||||||
|
Domain.where(registrant_id: registrant_ids)
|
||||||
|
|
||||||
|
domains.each { |domain| lift_force_delete(domain) if force_delete_condition(domain) }
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def lift_force_delete(domain)
|
||||||
|
domain.cancel_force_delete
|
||||||
|
end
|
||||||
|
|
||||||
|
def force_delete_condition(domain)
|
||||||
|
domain.force_delete_scheduled? &&
|
||||||
|
domain.template_name == 'invalid_email' &&
|
||||||
|
domain.contacts.all? { |contact| contact.email_verification.verified? } &&
|
||||||
|
domain.registrant.email_verification.verified?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -42,9 +42,11 @@ class EmailAddressVerification < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_force_delete
|
def check_force_delete
|
||||||
return unless failed?
|
if failed?
|
||||||
|
Domains::ForceDeleteEmail::Base.run(email: email)
|
||||||
Domains::ForceDeleteEmail::Base.run(email: email)
|
else
|
||||||
|
Domains::ForceDeleteLift::Base.run(email: email)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify
|
def verify
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue