mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 18:26:06 +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,
|
boolean :notify_by_email,
|
||||||
default: false,
|
default: false,
|
||||||
description: 'Do we need to send email notification'
|
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] }
|
validates :type, inclusion: { in: %i[fast_track soft] }
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Domains
|
||||||
send_email
|
send_email
|
||||||
domain.update(contact_notification_sent_date: Time.zone.today)
|
domain.update(contact_notification_sent_date: Time.zone.today)
|
||||||
else
|
else
|
||||||
domain.update(template_name: domain.notification_template)
|
domain.update(template_name: domain.notification_template(explicit: reason))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,10 @@ module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
|
||||||
end
|
end
|
||||||
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?
|
if contact_emails_verification_failed.present?
|
||||||
'invalid_email'
|
'invalid_email'
|
||||||
elsif registrant.org?
|
elsif registrant.org?
|
||||||
|
|
|
@ -23,7 +23,8 @@ class MassAction
|
||||||
dn = Domain.find_by(name_puny: e['domain_name'])
|
dn = Domain.find_by(name_puny: e['domain_name'])
|
||||||
log[:fail] << e['domain_name'] and next unless dn
|
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
|
log[:ok] << dn.name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ class MassAction
|
||||||
|
|
||||||
def self.force_delete_entries_valid?(entries)
|
def self.force_delete_entries_valid?(entries)
|
||||||
entries.each do |e|
|
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'])
|
return false unless e['domain_name'].present? && reasons.include?(e['delete_reason'])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
domain_name,delete_reason
|
domain_name,delete_reason
|
||||||
shop.test,ENTITY_BURIED
|
shop.test,ENTITY_BURIED
|
||||||
airport.test,PHONE
|
airport.test,INVALID_PHONE
|
||||||
library.test,EMAIL
|
library.test,INVALID_EMAIL
|
||||||
nonexistant.test,ENTITY_BURIED
|
nonexistant.test,ENTITY_BURIED
|
||||||
|
|
|
Loading…
Add table
Add a link
Reference in a new issue