mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 01:11:43 +02:00
Merge pull request #2476 from internetee/2467-force-delete-email-notifications
send expire email for multiyear domains
This commit is contained in:
commit
460216c319
5 changed files with 61 additions and 2 deletions
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -3,7 +3,7 @@ class DomainExpireEmailJob < ApplicationJob
|
|||
domain = Domain.find_by(id: domain_id)
|
||||
|
||||
return if domain.blank?
|
||||
return if domain.registered?
|
||||
return if domain.registered? && !domain.force_delete_scheduled?
|
||||
|
||||
attrs = {
|
||||
domain: domain,
|
||||
|
|
|
@ -516,6 +516,21 @@ class ForceDeleteTest < ActionMailer::TestCase
|
|||
assert_not @domain.force_delete_scheduled?
|
||||
end
|
||||
|
||||
def test_notification_multiyear_expiration_domain
|
||||
@domain.update(valid_to: Time.zone.parse('2014-08-05'))
|
||||
assert_not @domain.force_delete_scheduled?
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
||||
@domain.schedule_force_delete(type: :soft)
|
||||
@domain.reload
|
||||
|
||||
assert @domain.force_delete_scheduled?
|
||||
assert_equal Date.parse('2010-09-19'), @domain.force_delete_date.to_date
|
||||
assert_equal Date.parse('2010-08-05'), @domain.force_delete_start.to_date
|
||||
|
||||
assert_enqueued_jobs 8
|
||||
end
|
||||
|
||||
def prepare_bounced_email_address(email)
|
||||
@bounced_mail = BouncedMailAddress.new
|
||||
@bounced_mail.email = email
|
||||
|
|
|
@ -92,7 +92,6 @@ class EppResponseResultCodeTest < ActiveSupport::TestCase
|
|||
2400 => 'Command failed',
|
||||
2501 => 'Authentication error; server closing connection'
|
||||
}
|
||||
|
||||
assert Epp::Response::Result::Code.default_descriptions.contain? descriptions
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue