Add domain name to domain transfer message

#694
This commit is contained in:
Artur Beljajev 2018-02-19 03:51:32 +02:00
parent 6a7effac50
commit 4d7a222547
7 changed files with 21 additions and 25 deletions

View file

@ -57,14 +57,6 @@ class DomainTransfer < ActiveRecord::Base
status == PENDING status == PENDING
end end
def notify_losing_registrar(contacts, registrant)
old_registrar.messages.create!(
body: I18n.t('domain_transfer_was_approved', contacts: contacts, registrant: registrant),
attached_obj_id: id,
attached_obj_type: self.class.to_s
)
end
def approve def approve
transaction do transaction do
self.status = SERVER_APPROVED self.status = SERVER_APPROVED
@ -78,11 +70,14 @@ class DomainTransfer < ActiveRecord::Base
private private
def notify_old_registrar def notify_old_registrar
old_contacts_codes = domain.contacts.pluck(:code).sort.uniq old_contacts_codes = domain.contacts.pluck(:code).sort.uniq.join(', ')
old_registrant_code = domain.registrant.code old_registrant_code = domain.registrant.code
old_registrar.messages.create!( old_registrar.messages.create!(
body: I18n.t('domain_transfer_was_approved', contacts: old_contacts_codes, registrant: old_registrant_code), body: I18n.t('messages.texts.domain_transfer',
domain_name: domain.name,
old_contacts_codes: old_contacts_codes,
old_registrant_code: old_registrant_code),
attached_obj_id: id, attached_obj_id: id,
attached_obj_type: self.class.name attached_obj_type: self.class.name
) )

View file

@ -651,9 +651,6 @@ class Epp::Domain < Domain
} }
end end
old_contact_codes = contacts.pluck(:code).sort.uniq
old_registrant_code = registrant.code
transaction do transaction do
dt = domain_transfers.create!( dt = domain_transfers.create!(
transfer_requested_at: Time.zone.now, transfer_requested_at: Time.zone.now,
@ -670,8 +667,8 @@ class Epp::Domain < Domain
end end
if dt.approved? if dt.approved?
dt.send(:notify_old_registrar)
transfer_contacts(current_user.registrar) transfer_contacts(current_user.registrar)
dt.notify_losing_registrar(old_contact_codes, old_registrant_code)
regenerate_transfer_code regenerate_transfer_code
self.registrar = current_user.registrar self.registrar = current_user.registrar
end end

View file

@ -451,7 +451,6 @@ 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 were: %{contacts} and registrant was %{registrant}'
business_registry_service_not_available: "Business Registry service Ärireg is not available" business_registry_service_not_available: "Business Registry service Ärireg is not available"
# DEPP # DEPP

View file

@ -1,8 +1,7 @@
en: en:
activerecord: messages:
attributes: texts:
message/body: domain_transfer: >-
domain_transfer: >- Domain transfer of %{domain_name} has been approved.
Domain transfer of %{domain_name} has been approved. Old contacts: %{old_contacts_codes};
Old contacts: %{old_contacts}; old registrant: %{old_registrant_code}
old registrant: %{old_registrant}

View file

@ -47,7 +47,9 @@ class APIDomainTransfersTest < ActionDispatch::IntegrationTest
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key } post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
end end
message = 'Domain transfer was approved, associated contacts were: ["jane-001", "william-001"] and registrant was john-001' message = 'Domain transfer of shop.test has been approved.' \
' Old contacts: jane-001, william-001' \
'; old registrant: john-001'
assert_equal message, @old_registrar.messages.last.body assert_equal message, @old_registrar.messages.last.body
end end

View file

@ -46,7 +46,9 @@ class EppDomainTransferRequestTest < ActionDispatch::IntegrationTest
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' } post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
end end
message = 'Domain transfer was approved, associated contacts were: ["jane-001", "william-001"] and registrant was john-001' message = 'Domain transfer of shop.test has been approved.' \
' Old contacts: jane-001, william-001' \
'; old registrant: john-001'
assert_equal message, @old_registrar.messages.last.body assert_equal message, @old_registrar.messages.last.body
end end

View file

@ -18,7 +18,9 @@ class DomainTransferTest < ActiveSupport::TestCase
@domain_transfer.approve @domain_transfer.approve
end end
body = 'Domain transfer was approved, associated contacts were: ["jane-001", "william-001"] and registrant was john-001' body = 'Domain transfer of shop.test has been approved.' \
' Old contacts: jane-001, william-001' \
'; old registrant: john-001'
id = @domain_transfer.id id = @domain_transfer.id
class_name = @domain_transfer.class.name class_name = @domain_transfer.class.name