mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
Merge pull request #1830 from internetee/1828-send-poll-message-to-registrant-on-applying-and-removing-registry-lock
Registry lock: Notify Registrar by EPP notification
This commit is contained in:
commit
a3cca9149b
5 changed files with 50 additions and 7 deletions
|
@ -12,6 +12,7 @@ module Concerns
|
|||
statuses << DomainStatus::SERVER_DELETE_PROHIBITED
|
||||
statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED
|
||||
self.locked_by_registrant_at = Time.zone.now
|
||||
alert_registrar_lock_changes!(lock: true)
|
||||
|
||||
save!
|
||||
end
|
||||
|
@ -42,10 +43,21 @@ module Concerns
|
|||
statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
|
||||
statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED)
|
||||
self.locked_by_registrant_at = nil
|
||||
alert_registrar_lock_changes!(lock: false)
|
||||
|
||||
save!
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
|
|
@ -25,6 +25,10 @@ class Notification < ApplicationRecord
|
|||
''
|
||||
end
|
||||
|
||||
def registry_lock?
|
||||
text.include?('has been locked') || text.include?('has been unlocked')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_defaults
|
||||
|
|
|
@ -15,12 +15,22 @@ xml.epp_head do
|
|||
end if @object
|
||||
end
|
||||
|
||||
if @notification.action&.contact
|
||||
render(partial: 'epp/poll/action',
|
||||
locals: {
|
||||
builder: xml,
|
||||
action: @notification.action
|
||||
})
|
||||
if @notification.action&.contact || @notification.registry_lock?
|
||||
if @notification.registry_lock?
|
||||
state = @notification.text.include?('unlocked') ? 'unlock' : 'lock'
|
||||
xml.extension do
|
||||
xml.tag!('changePoll:changeData',
|
||||
'xmlns:changePoll': 'https://epp.tld.ee/schema/changePoll-1.0.xsd') do
|
||||
xml.tag!('changePoll:operation', state)
|
||||
end
|
||||
end
|
||||
else
|
||||
render(partial: 'epp/poll/action',
|
||||
locals: {
|
||||
builder: xml,
|
||||
action: @notification.action,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
render('epp/shared/trID', builder: xml)
|
||||
|
|
|
@ -6,3 +6,5 @@ en:
|
|||
It was associated with registrant %{old_registrant_code}
|
||||
and contacts %{old_contacts_codes}.
|
||||
contact_update: Contact %{contact} has been updated by registrant
|
||||
registrar_locked: Domain %{domain_name} has been locked by registrant
|
||||
registrar_unlocked: Domain %{domain_name} has been unlocked by registrant
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
require "test_helper"
|
||||
|
||||
class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
|
@ -19,6 +18,22 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
|
|||
super
|
||||
end
|
||||
|
||||
def test_registrant_locked_domain
|
||||
refute @domain.locked_by_registrant?
|
||||
@domain.apply_registry_lock
|
||||
assert @domain.locked_by_registrant?
|
||||
assert_equal(@domain.registrar.notifications.last.text, "Domain #{@domain.name} has been locked by registrant")
|
||||
end
|
||||
|
||||
def test_registrant_unlocked_domain
|
||||
refute @domain.locked_by_registrant?
|
||||
@domain.apply_registry_lock
|
||||
assert @domain.locked_by_registrant?
|
||||
@domain.remove_registry_lock
|
||||
refute @domain.locked_by_registrant?
|
||||
assert_equal(@domain.registrar.notifications.last.text, "Domain #{@domain.name} has been unlocked by registrant")
|
||||
end
|
||||
|
||||
def test_rejected_registrant_verification_notifies_registrar
|
||||
DomainUpdateConfirmJob.perform_now(@domain.id, RegistrantVerification::REJECTED)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue