-
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 #1430 from internetee/1428-new-force-delete-proced…
…ures Add new ForceDelete procedures
- Loading branch information
Showing
19 changed files
with
396 additions
and
53 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module Concerns | ||
module Job | ||
module ForceDelete | ||
extend ActiveSupport::Concern | ||
|
||
class_methods do | ||
def start_client_hold | ||
log_prepare_client_hold | ||
|
||
::PaperTrail.whodunnit = "cron - #{__method__}" | ||
|
||
::Domain.force_delete_scheduled.each do |domain| | ||
proceed_client_hold(domain: domain) | ||
log_end_end_client_hold(domain) | ||
end | ||
end | ||
|
||
def proceed_client_hold(domain:) | ||
notify_on_grace_period(domain) if domain.should_notify_on_soft_force_delete? | ||
return unless domain.client_holdable? | ||
|
||
domain.statuses << DomainStatus::CLIENT_HOLD | ||
log_start_client_hold(domain) | ||
|
||
domain.save(validate: false) | ||
notify_client_hold(domain) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module Concerns | ||
module Job | ||
module ForceDeleteLogging | ||
extend ActiveSupport::Concern | ||
|
||
class_methods do | ||
def log_prepare_client_hold | ||
return if Rails.env.test? | ||
|
||
STDOUT << "#{Time.zone.now.utc} - Setting client_hold to domains\n" | ||
end | ||
|
||
def log_start_client_hold(domain) | ||
return if Rails.env.test? | ||
|
||
STDOUT << "#{Time.zone.now.utc} DomainCron.start_client_hold: ##{domain.id} "\ | ||
"(#{domain.name}) #{domain.changes}\n" | ||
end | ||
|
||
def log_end_end_client_hold(domain) | ||
return if Rails.env.test? | ||
|
||
STDOUT << "#{Time.zone.now.utc} - Successfully set client_hold on (#{domain.name})" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module Concerns | ||
module Job | ||
module ForceDeleteNotify | ||
extend ActiveSupport::Concern | ||
|
||
class_methods do | ||
def notify_client_hold(domain) | ||
domain.registrar.notifications.create!(text: I18n.t('client_hold_set_on_domain', | ||
domain_name: domain.name, | ||
date: domain.force_delete_start)) | ||
end | ||
|
||
def notify_on_grace_period(domain) | ||
domain.registrar.notifications.create!(text: I18n.t('grace_period_started_domain', | ||
domain_name: domain.name, | ||
date: domain.force_delete_start)) | ||
send_mail(domain) | ||
domain.update(contact_notification_sent_date: Time.zone.today) | ||
end | ||
|
||
def send_mail(domain) | ||
DomainDeleteMailer.forced(domain: domain, | ||
registrar: domain.registrar, | ||
registrant: domain.registrant, | ||
template_name: domain.template_name).deliver_now | ||
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
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
5 changes: 5 additions & 0 deletions
5
db/migrate/20191203083643_add_force_delete_start_to_domains.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,5 @@ | ||
class AddForceDeleteStartToDomains < ActiveRecord::Migration[5.0] | ||
def change | ||
add_column :domains, :force_delete_start, :datetime | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20200115102202_add_force_delete_data_to_domains.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,5 @@ | ||
class AddForceDeleteDataToDomains < ActiveRecord::Migration[5.0] | ||
def change | ||
add_column :domains, :force_delete_data, :hstore | ||
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
Oops, something went wrong.