-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2476 from internetee/2467-force-delete-email-noti…
…fications send expire email for multiyear domains
- Loading branch information
Showing
5 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
app/interactions/domains/force_delete/notify_multiyears_expiration_domain.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module Domains | ||
module ForceDelete | ||
class NotifyMultiyearsExpirationDomain < Base | ||
SCHEDULED_DATA = 2.days | ||
MULTIYEAR_VALUE_START_LIMIT = 1.year | ||
|
||
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) >= MULTIYEAR_VALUE_START_LIMIT.to_i | ||
end | ||
|
||
def recipients | ||
filter_invalid_emails(domain.expired_domain_contact_emails) | ||
end | ||
|
||
def filter_invalid_emails(emails) | ||
emails.select do |email| | ||
valid = Rails.env.test? ? true : 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters