Notify losing registrar

This commit is contained in:
Martin Lensment 2015-04-02 18:28:13 +03:00
parent 642eda06fd
commit 830c2a9497
5 changed files with 31 additions and 9 deletions

View file

@ -13,8 +13,13 @@ class DomainTransfer < ActiveRecord::Base
SERVER_CANCELLED = 'serverCancelled' SERVER_CANCELLED = 'serverCancelled'
before_create :set_wait_until 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 def set_status
if Setting.transfer_wait_time > 0 if Setting.transfer_wait_time > 0
self.status = PENDING unless status self.status = PENDING unless status
@ -26,12 +31,6 @@ class DomainTransfer < ActiveRecord::Base
delegate :name, :valid_to, to: :domain, prefix: true 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? def approved?
status == CLIENT_APPROVED || status == SERVER_APPROVED status == CLIENT_APPROVED || status == SERVER_APPROVED
end end
@ -51,4 +50,12 @@ class DomainTransfer < ActiveRecord::Base
domain.save(validate: false) domain.save(validate: false)
end end
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 end

View file

@ -512,6 +512,7 @@ class Epp::Domain < Domain
if dt.approved? if dt.approved?
transfer_contacts(current_user.registrar_id) transfer_contacts(current_user.registrar_id)
dt.notify_losing_registrar
generate_auth_info generate_auth_info
self.registrar = current_user.registrar self.registrar = current_user.registrar
end end

View file

@ -511,3 +511,4 @@ en:
client_side_status_editing_error: 'Parameter value policy error. Client-side object status management not supported' client_side_status_editing_error: 'Parameter value policy error. Client-side object status management not supported'
switch_to: Switch to switch_to: Switch to
admin_menu: Admin admin_menu: Admin
domain_transfer_was_approved: 'Domain transfer was approved, associated contacts are: %{contacts}'

View file

@ -736,6 +736,16 @@ describe 'EPP Domain', epp: true do
domain.registrar.should == @registrar2 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 Setting.transfer_wait_time = 1
domain.reload domain.reload

View file

@ -1,2 +1,5 @@
Fabricator(:domain_transfer) do Fabricator(:domain_transfer) do
domain
transfer_from { Fabricate(:registrar) }
transfer_to { Fabricate(:registrar) }
end end