-
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.
separete responsibility of different pieces of code
- Loading branch information
Oleg Hasjanov
committed
Apr 7, 2021
1 parent
da31721
commit 3985513
Showing
3 changed files
with
50 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
31 changes: 31 additions & 0 deletions
31
app/interactions/domains/registry_lock_domain/set_registry_lock_domain.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,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 |
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