mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 05:26:17 +02:00
send expire email for multiyear domains
This commit is contained in:
parent
f2cd7cb20a
commit
17b9cf0ffc
4 changed files with 66 additions and 2 deletions
|
@ -0,0 +1,46 @@
|
|||
module Domains
|
||||
module ForceDelete
|
||||
class NotifyMultiyearsExpirationDomain < Base
|
||||
SCHEDULED_DATA = 2.days
|
||||
|
||||
def execute
|
||||
return unless multiyear_registrations?
|
||||
|
||||
recipients.each do |recipient|
|
||||
DomainExpireEmailJob.set(wait_until: send_time).perform_later(domain.id, recipient)
|
||||
end
|
||||
end
|
||||
|
||||
def send_time
|
||||
domain.force_delete_start + SCHEDULED_DATA
|
||||
end
|
||||
|
||||
def multiyear_registrations?
|
||||
domain_expire = domain.valid_to.to_i
|
||||
current_time = Time.zone.now.to_i
|
||||
|
||||
(domain_expire - current_time) >= 1.year.to_i
|
||||
end
|
||||
|
||||
def recipients
|
||||
filter_invalid_emails(domain.expired_domain_contact_emails)
|
||||
end
|
||||
|
||||
def filter_invalid_emails(emails)
|
||||
emails.select do |email|
|
||||
valid = Truemail.valid?(email)
|
||||
|
||||
unless valid
|
||||
Rails.logger.info('Unable to send DomainExpireMailer#expired email for '\
|
||||
"domain #{domain.name} (##{domain.id}) to invalid recipient #{email}")
|
||||
end
|
||||
|
||||
valid
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -8,6 +8,7 @@ module Domains
|
|||
compose(PostSetProcess, inputs.to_h)
|
||||
compose(NotifyRegistrar, inputs.to_h)
|
||||
compose(NotifyByEmail, inputs.to_h)
|
||||
compose(NotifyMultiyearsExpirationDomain, inputs.to_h)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue