diff --git a/app/models/domain_transfer.rb b/app/models/domain_transfer.rb index 42f531030..6982f36b6 100644 --- a/app/models/domain_transfer.rb +++ b/app/models/domain_transfer.rb @@ -57,14 +57,6 @@ class DomainTransfer < ActiveRecord::Base status == PENDING 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 transaction do self.status = SERVER_APPROVED @@ -78,11 +70,14 @@ class DomainTransfer < ActiveRecord::Base private 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_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_type: self.class.name ) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 033640c1e..32a8a2198 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -651,9 +651,6 @@ class Epp::Domain < Domain } end - old_contact_codes = contacts.pluck(:code).sort.uniq - old_registrant_code = registrant.code - transaction do dt = domain_transfers.create!( transfer_requested_at: Time.zone.now, @@ -670,8 +667,8 @@ class Epp::Domain < Domain end if dt.approved? + dt.send(:notify_old_registrar) transfer_contacts(current_user.registrar) - dt.notify_losing_registrar(old_contact_codes, old_registrant_code) regenerate_transfer_code self.registrar = current_user.registrar end diff --git a/config/locales/en.yml b/config/locales/en.yml index da6df608a..38b9c1973 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -451,7 +451,6 @@ 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 were: %{contacts} and registrant was %{registrant}' business_registry_service_not_available: "Business Registry service Ärireg is not available" # DEPP diff --git a/config/locales/messages.en.yml b/config/locales/messages.en.yml index 5cc945c25..2827a2f18 100644 --- a/config/locales/messages.en.yml +++ b/config/locales/messages.en.yml @@ -1,8 +1,7 @@ en: - activerecord: - attributes: - message/body: - domain_transfer: >- - Domain transfer of %{domain_name} has been approved. - Old contacts: %{old_contacts}; - old registrant: %{old_registrant} + messages: + texts: + domain_transfer: >- + Domain transfer of %{domain_name} has been approved. + Old contacts: %{old_contacts_codes}; + old registrant: %{old_registrant_code} diff --git a/test/integration/api/domain_transfers_test.rb b/test/integration/api/domain_transfers_test.rb index 47730e475..acae0e2e0 100644 --- a/test/integration/api/domain_transfers_test.rb +++ b/test/integration/api/domain_transfers_test.rb @@ -47,7 +47,9 @@ class APIDomainTransfersTest < ActionDispatch::IntegrationTest post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key } 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 end diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index ce00d1fdb..e83bfb2e4 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -46,7 +46,9 @@ class EppDomainTransferRequestTest < ActionDispatch::IntegrationTest post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' } 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 end diff --git a/test/models/domain_transfer_test.rb b/test/models/domain_transfer_test.rb index 12f36d459..3d1e8edd9 100644 --- a/test/models/domain_transfer_test.rb +++ b/test/models/domain_transfer_test.rb @@ -18,7 +18,9 @@ class DomainTransferTest < ActiveSupport::TestCase @domain_transfer.approve 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 class_name = @domain_transfer.class.name