Merge branch 'master' into 93-locked-domains-failed-after-fc

This commit is contained in:
OlegPhenomenon 2021-09-24 09:32:27 +03:00 committed by GitHub
commit ab26100e78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 269 additions and 69 deletions

View file

@ -1,7 +1,7 @@
module Domain::RegistryLockable
extend ActiveSupport::Concern
LOCK_STATUSES = if Feature.obj_and_extensions_statuses_enabled?
LOCK_STATUSES = if Feature.enable_lock_domain_with_new_statuses?
[DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED,
DomainStatus::SERVER_DELETE_PROHIBITED,
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
@ -11,20 +11,26 @@ module Domain::RegistryLockable
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
end
def apply_registry_lock
EXTENSIONS_STATUS = [DomainStatus::SERVER_EXTENSION_UPDATE_PROHIBITED].freeze
def apply_registry_lock(extensions_prohibited:)
return unless registry_lockable?
return if locked_by_registrant?
transaction do
self.admin_store_statuses_history = self.statuses
self.statuses |= LOCK_STATUSES
self.locked_by_registrant_at = Time.zone.now
alert_registrar_lock_changes!(lock: true)
save!
apply_statuses_locked_statuses(extensions_prohibited: extensions_prohibited)
end
end
def apply_statuses_locked_statuses(extensions_prohibited:)
self.statuses |= LOCK_STATUSES
self.statuses |= EXTENSIONS_STATUS if Feature.obj_and_extensions_statuses_enabled? && extensions_prohibited
self.locked_by_registrant_at = Time.zone.now
alert_registrar_lock_changes!(lock: true)
save!
end
def registry_lockable?
(statuses & [DomainStatus::PENDING_DELETE_CONFIRMATION,
DomainStatus::PENDING_CREATE, DomainStatus::PENDING_UPDATE,
@ -42,17 +48,23 @@ module Domain::RegistryLockable
return unless locked_by_registrant?
transaction do
LOCK_STATUSES.each do |domain_status|
statuses.delete([domain_status])
end
self.locked_by_registrant_at = nil
self.statuses = admin_store_statuses_history || []
alert_registrar_lock_changes!(lock: false)
save!
remove_statuses_from_locked_domain
end
end
def remove_statuses_from_locked_domain
LOCK_STATUSES.each do |domain_status|
statuses.delete([domain_status])
end
statuses.delete([EXTENSIONS_STATUS]) if statuses.include? EXTENSIONS_STATUS
self.locked_by_registrant_at = nil
self.statuses = admin_store_statuses_history || []
alert_registrar_lock_changes!(lock: false)
save!
end
def alert_registrar_lock_changes!(lock: true)
translation = lock ? 'locked' : 'unlocked'
registrar.notifications.create!(

View file

@ -4,4 +4,10 @@ class Feature
ENV['obj_and_extensions_prohibited'] || false
end
def self.enable_lock_domain_with_new_statuses?
return false if ENV['enable_lock_domain_with_new_statuses'] == 'false'
ENV['enable_lock_domain_with_new_statuses'] || false
end
end

View file

@ -23,7 +23,7 @@ class RegistrantUser < User
company_register.representation_rights(citizen_personal_code: ident,
citizen_country_code: country.alpha3)
end
def contacts(representable: true)
Contact.registrant_user_contacts(self, representable: representable)
end