mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Notify losing registrar
This commit is contained in:
parent
642eda06fd
commit
830c2a9497
5 changed files with 31 additions and 9 deletions
|
@ -13,8 +13,13 @@ class DomainTransfer < ActiveRecord::Base
|
|||
SERVER_CANCELLED = 'serverCancelled'
|
||||
|
||||
before_create :set_wait_until
|
||||
before_create :set_status
|
||||
def set_wait_until
|
||||
wait_time = Setting.transfer_wait_time
|
||||
return if wait_time == 0
|
||||
self.wait_until = transfer_requested_at + wait_time.hours
|
||||
end
|
||||
|
||||
before_create :set_status
|
||||
def set_status
|
||||
if Setting.transfer_wait_time > 0
|
||||
self.status = PENDING unless status
|
||||
|
@ -26,12 +31,6 @@ class DomainTransfer < ActiveRecord::Base
|
|||
|
||||
delegate :name, :valid_to, to: :domain, prefix: true
|
||||
|
||||
def set_wait_until
|
||||
wait_time = Setting.transfer_wait_time
|
||||
return if wait_time == 0
|
||||
self.wait_until = transfer_requested_at + wait_time.hours
|
||||
end
|
||||
|
||||
def approved?
|
||||
status == CLIENT_APPROVED || status == SERVER_APPROVED
|
||||
end
|
||||
|
@ -51,4 +50,12 @@ class DomainTransfer < ActiveRecord::Base
|
|||
domain.save(validate: false)
|
||||
end
|
||||
end
|
||||
|
||||
def notify_losing_registrar
|
||||
transfer_from.messages.create!(
|
||||
body: I18n.t('domain_transfer_was_approved', contacts: domain.contacts.pluck(:code)),
|
||||
attached_obj_id: id,
|
||||
attached_obj_type: self.class.to_s
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -160,7 +160,7 @@ class Epp::Domain < Domain
|
|||
def admin_domain_contacts_attrs(frame, action)
|
||||
admin_attrs = domain_contact_attrs_from(frame, action, 'admin')
|
||||
|
||||
case action
|
||||
case action
|
||||
when 'rem'
|
||||
return destroy_attrs(admin_attrs, admin_domain_contacts)
|
||||
else
|
||||
|
@ -171,7 +171,7 @@ class Epp::Domain < Domain
|
|||
def tech_domain_contacts_attrs(frame, action)
|
||||
tech_attrs = domain_contact_attrs_from(frame, action, 'tech')
|
||||
|
||||
case action
|
||||
case action
|
||||
when 'rem'
|
||||
return destroy_attrs(tech_attrs, tech_domain_contacts)
|
||||
else
|
||||
|
@ -512,6 +512,7 @@ class Epp::Domain < Domain
|
|||
|
||||
if dt.approved?
|
||||
transfer_contacts(current_user.registrar_id)
|
||||
dt.notify_losing_registrar
|
||||
generate_auth_info
|
||||
self.registrar = current_user.registrar
|
||||
end
|
||||
|
|
|
@ -511,3 +511,4 @@ en:
|
|||
client_side_status_editing_error: 'Parameter value policy error. Client-side object status management not supported'
|
||||
switch_to: Switch to
|
||||
admin_menu: Admin
|
||||
domain_transfer_was_approved: 'Domain transfer was approved, associated contacts are: %{contacts}'
|
||||
|
|
|
@ -736,6 +736,16 @@ describe 'EPP Domain', epp: true do
|
|||
|
||||
domain.registrar.should == @registrar2
|
||||
|
||||
response = epp_plain_request(@epp_xml.session.poll, :xml)
|
||||
|
||||
response[:msg].should == 'Command completed successfully; ack to dequeue'
|
||||
msg_q = response[:parsed].css('msgQ')
|
||||
msg_q.css('qDate').text.should_not be_blank
|
||||
contacts = domain.contacts.pluck(:code)
|
||||
msg_q.css('msg').text.should == "Domain transfer was approved, associated contacts are: #{contacts}"
|
||||
msg_q.first['id'].should_not be_blank
|
||||
msg_q.first['count'].should == '1'
|
||||
|
||||
Setting.transfer_wait_time = 1
|
||||
|
||||
domain.reload
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
Fabricator(:domain_transfer) do
|
||||
domain
|
||||
transfer_from { Fabricate(:registrar) }
|
||||
transfer_to { Fabricate(:registrar) }
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue