mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 02:05:57 +02:00
Allow explicit reason for force delete mail template
This commit is contained in:
parent
8a046b59bf
commit
38cefe7255
5 changed files with 13 additions and 6 deletions
|
@ -10,6 +10,9 @@ module Domains
|
|||
boolean :notify_by_email,
|
||||
default: false,
|
||||
description: 'Do we need to send email notification'
|
||||
string :reason,
|
||||
default: nil,
|
||||
description: 'Which mail template to use explicitly'
|
||||
|
||||
validates :type, inclusion: { in: %i[fast_track soft] }
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ module Domains
|
|||
send_email
|
||||
domain.update(contact_notification_sent_date: Time.zone.today)
|
||||
else
|
||||
domain.update(template_name: domain.notification_template)
|
||||
domain.update(template_name: domain.notification_template(explicit: reason))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -19,7 +19,10 @@ module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
|
|||
end
|
||||
end
|
||||
|
||||
def notification_template
|
||||
def notification_template(explicit: nil)
|
||||
reason = explicit&.downcase
|
||||
return reason if %w[invalid_email invalid_phone].include?(reason)
|
||||
|
||||
if contact_emails_verification_failed.present?
|
||||
'invalid_email'
|
||||
elsif registrant.org?
|
||||
|
|
|
@ -23,7 +23,8 @@ class MassAction
|
|||
dn = Domain.find_by(name_puny: e['domain_name'])
|
||||
log[:fail] << e['domain_name'] and next unless dn
|
||||
|
||||
dn.schedule_force_delete(type: :soft, reason: e['delete_reason'])
|
||||
dn.schedule_force_delete(type: :soft, notify_by_email: false, reason: e['delete_reason'])
|
||||
|
||||
log[:ok] << dn.name
|
||||
end
|
||||
|
||||
|
@ -32,7 +33,7 @@ class MassAction
|
|||
|
||||
def self.force_delete_entries_valid?(entries)
|
||||
entries.each do |e|
|
||||
reasons = %w[ENTITY_BURIED EMAIL PHONE]
|
||||
reasons = %w[ENTITY_BURIED INVALID_EMAIL INVALID_PHONE]
|
||||
return false unless e['domain_name'].present? && reasons.include?(e['delete_reason'])
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
domain_name,delete_reason
|
||||
shop.test,ENTITY_BURIED
|
||||
airport.test,PHONE
|
||||
library.test,EMAIL
|
||||
airport.test,INVALID_PHONE
|
||||
library.test,INVALID_EMAIL
|
||||
nonexistant.test,ENTITY_BURIED
|
||||
|
|
|
Loading…
Add table
Add a link
Reference in a new issue