mirror of
https://github.com/internetee/registry.git
synced 2025-06-12 23:54:44 +02:00
separete responsibility of different pieces of code
This commit is contained in:
parent
da3172169a
commit
3985513407
3 changed files with 49 additions and 6 deletions
9
app/interactions/domains/registry_lock_domain/base.rb
Normal file
9
app/interactions/domains/registry_lock_domain/base.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
module Domain::RegistryLockable
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
class Base < ActiveInteraction::Base
|
||||||
|
object :domain,
|
||||||
|
class: Domain,
|
||||||
|
description: 'Domain to set ForceDelete on'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
module Domain::RegistryLockable
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
class SetRegistratLock < Base
|
||||||
|
LOCK_STATUSES = [DomainStatus::SERVER_UPDATE_PROHIBITED,
|
||||||
|
DomainStatus::SERVER_DELETE_PROHIBITED,
|
||||||
|
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
|
||||||
|
|
||||||
|
def execute
|
||||||
|
transaction do
|
||||||
|
self.statuses |= LOCK_STATUSES
|
||||||
|
self.locked_by_registrant_at = Time.zone.now
|
||||||
|
alert_registrar_lock_changes!(lock: true)
|
||||||
|
|
||||||
|
save!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def alert_registrar_lock_changes!(lock: true)
|
||||||
|
translation = lock ? 'locked' : 'unlocked'
|
||||||
|
registrar.notifications.create!(
|
||||||
|
text: I18n.t("notifications.texts.registrar_#{translation}",
|
||||||
|
domain_name: name),
|
||||||
|
attached_obj_id: name,
|
||||||
|
attached_obj_type: self.class.name
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,13 +11,16 @@ module Domain::RegistryLockable
|
||||||
|
|
||||||
save_statuses_history
|
save_statuses_history
|
||||||
|
|
||||||
transaction do
|
# transaction do
|
||||||
self.statuses |= LOCK_STATUSES
|
# self.statuses |= LOCK_STATUSES
|
||||||
self.locked_by_registrant_at = Time.zone.now
|
# self.locked_by_registrant_at = Time.zone.now
|
||||||
alert_registrar_lock_changes!(lock: true)
|
# alert_registrar_lock_changes!(lock: true)
|
||||||
|
|
||||||
save!
|
# save!
|
||||||
end
|
# end
|
||||||
|
# Domains::ForceDelete::SetForceDelete.run(domain: self, type: type, reason: reason,
|
||||||
|
# notify_by_email: notify_by_email, email: email)
|
||||||
|
Domain::RegistryLockable::SetRegistratLock.run(domain: self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def registry_lockable?
|
def registry_lockable?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue