mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 01:11:43 +02:00
Add notification on autoFD
This commit is contained in:
parent
81c21db392
commit
91093b274d
6 changed files with 42 additions and 10 deletions
|
@ -13,6 +13,9 @@ module Domains
|
|||
string :reason,
|
||||
default: nil,
|
||||
description: 'Which mail template to use explicitly'
|
||||
string :email,
|
||||
default: nil,
|
||||
description: 'Possible invalid email to notify on'
|
||||
|
||||
validates :type, inclusion: { in: %i[fast_track soft] }
|
||||
end
|
||||
|
|
|
@ -2,11 +2,23 @@ module Domains
|
|||
module ForceDelete
|
||||
class NotifyRegistrar < Base
|
||||
def execute
|
||||
email.present? ? notify_with_email : notify_without_email
|
||||
end
|
||||
|
||||
def notify_without_email
|
||||
domain.registrar.notifications.create!(text: I18n.t('force_delete_set_on_domain',
|
||||
domain_name: domain.name,
|
||||
outzone_date: domain.outzone_date,
|
||||
purge_date: domain.purge_date))
|
||||
end
|
||||
|
||||
def notify_with_email
|
||||
domain.registrar.notifications.create!(text: I18n.t('force_delete_auto_email',
|
||||
domain_name: domain.name,
|
||||
outzone_date: domain.outzone_date,
|
||||
purge_date: domain.purge_date,
|
||||
email: email))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,12 +11,16 @@ module Domains
|
|||
domains = domain_contacts.map(&:domain).flatten +
|
||||
Domain.where(registrant_id: registrant_ids)
|
||||
|
||||
domains.each do |domain|
|
||||
next if domain.force_delete_scheduled?
|
||||
domains.each { |domain| process_force_delete(domain) unless domain.force_delete_scheduled? }
|
||||
end
|
||||
|
||||
domain.schedule_force_delete(type: :soft,
|
||||
notify_by_email: true, reason: 'invalid_email')
|
||||
end
|
||||
private
|
||||
|
||||
def process_force_delete(domain)
|
||||
domain.schedule_force_delete(type: :soft,
|
||||
notify_by_email: true,
|
||||
reason: 'invalid_email',
|
||||
email: email)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,9 +45,9 @@ module Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
|
|||
statuses.include?(DomainStatus::FORCE_DELETE)
|
||||
end
|
||||
|
||||
def schedule_force_delete(type: :fast_track, notify_by_email: false, reason: nil)
|
||||
def schedule_force_delete(type: :fast_track, notify_by_email: false, reason: nil, email: nil)
|
||||
Domains::ForceDelete::SetForceDelete.run(domain: self, type: type, reason: reason,
|
||||
notify_by_email: notify_by_email)
|
||||
notify_by_email: notify_by_email, email: email)
|
||||
end
|
||||
|
||||
def cancel_force_delete
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue