mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 09:43:36 +02:00
Remove manual rescues from transfer code #2588
This commit is contained in:
parent
812381056c
commit
91da0d30f0
3 changed files with 52 additions and 64 deletions
|
@ -130,10 +130,14 @@ class Epp::DomainsController < EppController
|
||||||
|
|
||||||
@domain_transfer = @domain.transfer(params[:parsed_frame], action, current_user)
|
@domain_transfer = @domain.transfer(params[:parsed_frame], action, current_user)
|
||||||
|
|
||||||
if @domain.errors.empty? && @domain_transfer
|
if @domain_transfer
|
||||||
render_epp_response '/epp/domains/transfer'
|
render_epp_response '/epp/domains/transfer'
|
||||||
else
|
else
|
||||||
handle_errors(@domain)
|
epp_errors << {
|
||||||
|
code: '2303',
|
||||||
|
msg: I18n.t('no_transfers_found')
|
||||||
|
}
|
||||||
|
handle_errors
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -473,7 +473,6 @@ class Epp::Domain < Domain
|
||||||
when 'reject'
|
when 'reject'
|
||||||
return reject_transfer(frame, current_user) if pending_transfer
|
return reject_transfer(frame, current_user) if pending_transfer
|
||||||
end
|
end
|
||||||
add_epp_error('2303', nil, nil, I18n.t('no_transfers_found'))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Eager load problems here. Investigate how it's possible not to query contact again
|
# TODO: Eager load problems here. Investigate how it's possible not to query contact again
|
||||||
|
@ -536,19 +535,23 @@ class Epp::Domain < Domain
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop: enable Metrics/PerceivedComplexity
|
# rubocop: enable Metrics/PerceivedComplexity
|
||||||
# rubocop: enable Metrics/CyclomaticComplexity
|
# rubocop: enable Metrics/CyclomaticComplexity
|
||||||
|
|
||||||
# rubocop: disable Metrics/MethodLength
|
# rubocop: disable Metrics/MethodLength
|
||||||
# rubocop: disable Metrics/AbcSize
|
# rubocop: disable Metrics/AbcSize
|
||||||
def query_transfer(frame, current_user)
|
def query_transfer(frame, current_user)
|
||||||
return false unless can_be_transferred_to?(current_user.registrar)
|
unless can_be_transferred_to?(current_user.registrar)
|
||||||
|
throw :epp_error, {
|
||||||
|
code: '2002',
|
||||||
|
msg: I18n.t(:domain_already_belongs_to_the_querying_registrar)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
old_contact_codes = contacts.pluck(:code).sort.uniq
|
old_contact_codes = contacts.pluck(:code).sort.uniq
|
||||||
old_registrant_code = registrant.code
|
old_registrant_code = registrant.code
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
begin
|
|
||||||
dt = domain_transfers.create!(
|
dt = domain_transfers.create!(
|
||||||
transfer_requested_at: Time.zone.now,
|
transfer_requested_at: Time.zone.now,
|
||||||
transfer_to: current_user.registrar,
|
transfer_to: current_user.registrar,
|
||||||
|
@ -574,12 +577,6 @@ class Epp::Domain < Domain
|
||||||
save!(validate: false)
|
save!(validate: false)
|
||||||
|
|
||||||
return dt
|
return dt
|
||||||
rescue => e
|
|
||||||
add_epp_error('2306', nil, nil, I18n.t('action_failed_due_to_server_error'))
|
|
||||||
logger.error('DOMAIN TRANSFER FAILED')
|
|
||||||
logger.error(e)
|
|
||||||
raise ActiveRecord::Rollback
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# rubocop: enable Metrics/AbcSize
|
# rubocop: enable Metrics/AbcSize
|
||||||
|
@ -595,7 +592,6 @@ class Epp::Domain < Domain
|
||||||
end
|
end
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
begin
|
|
||||||
pt.update!(
|
pt.update!(
|
||||||
status: DomainTransfer::CLIENT_APPROVED,
|
status: DomainTransfer::CLIENT_APPROVED,
|
||||||
transferred_at: Time.zone.now
|
transferred_at: Time.zone.now
|
||||||
|
@ -607,10 +603,6 @@ class Epp::Domain < Domain
|
||||||
|
|
||||||
attach_legal_document(self.class.parse_legal_document_from_frame(frame))
|
attach_legal_document(self.class.parse_legal_document_from_frame(frame))
|
||||||
save!(validate: false)
|
save!(validate: false)
|
||||||
rescue => _e
|
|
||||||
add_epp_error('2306', nil, nil, I18n.t('action_failed_due_to_server_error'))
|
|
||||||
raise ActiveRecord::Rollback
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
pt
|
pt
|
||||||
|
@ -626,17 +618,12 @@ class Epp::Domain < Domain
|
||||||
end
|
end
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
begin
|
|
||||||
pt.update!(
|
pt.update!(
|
||||||
status: DomainTransfer::CLIENT_REJECTED
|
status: DomainTransfer::CLIENT_REJECTED
|
||||||
)
|
)
|
||||||
|
|
||||||
attach_legal_document(self.class.parse_legal_document_from_frame(frame))
|
attach_legal_document(self.class.parse_legal_document_from_frame(frame))
|
||||||
save!(validate: false)
|
save!(validate: false)
|
||||||
rescue => _e
|
|
||||||
add_epp_error('2306', nil, nil, I18n.t('action_failed_due_to_server_error'))
|
|
||||||
raise ActiveRecord::Rollback
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
pt
|
pt
|
||||||
|
@ -713,11 +700,7 @@ class Epp::Domain < Domain
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_be_transferred_to?(new_registrar)
|
def can_be_transferred_to?(new_registrar)
|
||||||
if new_registrar == registrar
|
new_registrar != registrar
|
||||||
errors.add(:base, :domain_already_belongs_to_the_querying_registrar)
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
## SHARED
|
## SHARED
|
||||||
|
|
|
@ -872,3 +872,4 @@ en:
|
||||||
payment_received: 'Payment received'
|
payment_received: 'Payment received'
|
||||||
domain_registrant_updated: 'Domeeni %{name} registreerija vahetus teostatud / Registrant change of %{name} has been finished.'
|
domain_registrant_updated: 'Domeeni %{name} registreerija vahetus teostatud / Registrant change of %{name} has been finished.'
|
||||||
api_user_not_found: 'API user not found'
|
api_user_not_found: 'API user not found'
|
||||||
|
domain_already_belongs_to_the_querying_registrar: 'Domain already belongs to the querying registrar'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue