mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 13:44:47 +02:00
Revert "Revert "Domain transfer: remove duplicate domain_contacts on transfer""
This commit is contained in:
parent
cbd8263efb
commit
7b170b5026
1 changed files with 7 additions and 2 deletions
|
@ -57,7 +57,8 @@ module Concerns::Domain::Transferable
|
||||||
|
|
||||||
def transfer_domain_contacts(new_registrar)
|
def transfer_domain_contacts(new_registrar)
|
||||||
copied_ids = []
|
copied_ids = []
|
||||||
contacts.each do |contact|
|
domain_contacts.each do |dc|
|
||||||
|
contact = Contact.find(dc.contact_id)
|
||||||
next if copied_ids.include?(contact.id) || contact.registrar == new_registrar
|
next if copied_ids.include?(contact.id) || contact.registrar == new_registrar
|
||||||
|
|
||||||
if registrant_id_was == contact.id # registrant was copied previously, do not copy it again
|
if registrant_id_was == contact.id # registrant was copied previously, do not copy it again
|
||||||
|
@ -66,7 +67,11 @@ module Concerns::Domain::Transferable
|
||||||
oc = contact.transfer(new_registrar)
|
oc = contact.transfer(new_registrar)
|
||||||
end
|
end
|
||||||
|
|
||||||
domain_contacts.where(contact_id: contact.id).update_all({ contact_id: oc.id }) # n+1 workaround
|
if domain_contacts.find_by(contact_id: oc.id, domain_id: id, type: dc.type).present?
|
||||||
|
dc.destroy
|
||||||
|
else
|
||||||
|
dc.update(contact_id: oc.id)
|
||||||
|
end
|
||||||
copied_ids << contact.id
|
copied_ids << contact.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue