diff --git a/app/interactions/domains/registry_lock_domain/base.rb b/app/interactions/domains/registry_lock_domain/base.rb new file mode 100644 index 000000000..0f8897589 --- /dev/null +++ b/app/interactions/domains/registry_lock_domain/base.rb @@ -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 + \ No newline at end of file diff --git a/app/interactions/domains/registry_lock_domain/set_registry_lock_domain.rb b/app/interactions/domains/registry_lock_domain/set_registry_lock_domain.rb new file mode 100644 index 000000000..2092c0184 --- /dev/null +++ b/app/interactions/domains/registry_lock_domain/set_registry_lock_domain.rb @@ -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 \ No newline at end of file diff --git a/app/models/concerns/domain/registry_lockable.rb b/app/models/concerns/domain/registry_lockable.rb index d7affb8d1..cf9e7f383 100644 --- a/app/models/concerns/domain/registry_lockable.rb +++ b/app/models/concerns/domain/registry_lockable.rb @@ -11,13 +11,16 @@ module Domain::RegistryLockable save_statuses_history - transaction do - self.statuses |= LOCK_STATUSES - self.locked_by_registrant_at = Time.zone.now - alert_registrar_lock_changes!(lock: true) + # transaction do + # self.statuses |= LOCK_STATUSES + # self.locked_by_registrant_at = Time.zone.now + # alert_registrar_lock_changes!(lock: true) - save! - end + # save! + # 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 def registry_lockable?