mirror of
https://github.com/internetee/registry.git
synced 2025-08-06 01:35:10 +02:00
Cache contact code for epp eager errors
This commit is contained in:
parent
8aac684df7
commit
ddd91d464a
9 changed files with 42 additions and 14 deletions
|
@ -43,7 +43,7 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
before_create :generate_auth_info
|
||||
before_create :set_validity_dates
|
||||
after_create :attach_default_contacts
|
||||
before_create :attach_default_contacts
|
||||
after_save :manage_automatic_statuses
|
||||
|
||||
validates :name_dirty, domain_name: true, uniqueness: true
|
||||
|
@ -186,7 +186,7 @@ class Domain < ActiveRecord::Base
|
|||
next unless existing.length > 1
|
||||
validated << dc
|
||||
errors.add(:domain_contacts, :invalid) if errors[:domain_contacts].blank?
|
||||
dc.errors.add(:contact, :taken)
|
||||
dc.errors.add(:contact_code_cache, :taken)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -280,8 +280,22 @@ class Domain < ActiveRecord::Base
|
|||
# rubocop:enable Lint/Loop
|
||||
|
||||
def attach_default_contacts
|
||||
tech_contacts << owner_contact if tech_contacts_count.zero?
|
||||
admin_contacts << owner_contact if admin_contacts_count.zero? && owner_contact.citizen?
|
||||
if tech_contacts_count.zero?
|
||||
attach_contact(DomainContact::TECH, owner_contact)
|
||||
end
|
||||
|
||||
return unless admin_contacts_count.zero? && owner_contact.citizen?
|
||||
attach_contact(DomainContact::ADMIN, owner_contact)
|
||||
end
|
||||
|
||||
def attach_contact(type, contact)
|
||||
domain_contacts.build(
|
||||
contact: contact, contact_type: DomainContact::TECH, contact_code_cache: contact.code
|
||||
) if type.to_sym == :tech
|
||||
|
||||
domain_contacts.build(
|
||||
contact: contact, contact_type: DomainContact::ADMIN, contact_code_cache: contact.code
|
||||
) if type.to_sym == :admin
|
||||
end
|
||||
|
||||
def set_validity_dates
|
||||
|
|
|
@ -12,7 +12,7 @@ class DomainContact < ActiveRecord::Base
|
|||
def epp_code_map
|
||||
{
|
||||
'2302' => [
|
||||
[:contact, :taken, { value: { obj: 'contact', val: contact.code } }]
|
||||
[:contact_code_cache, :taken, { value: { obj: 'contact', val: contact_code_cache } }]
|
||||
]
|
||||
}
|
||||
end
|
||||
|
|
|
@ -121,11 +121,6 @@ class Epp::EppDomain < Domain
|
|||
attach_contact(DomainContact::ADMIN, owner_contact) if admin_contacts_count.zero? && owner_contact.citizen?
|
||||
end
|
||||
|
||||
def attach_contact(type, contact)
|
||||
domain_contacts.build(contact: contact, contact_type: DomainContact::TECH) if type.to_sym == :tech
|
||||
domain_contacts.build(contact: contact, contact_type: DomainContact::ADMIN) if type.to_sym == :admin
|
||||
end
|
||||
|
||||
def attach_nameservers(ns_list)
|
||||
ns_list.each do |ns_attrs|
|
||||
nameservers.build(ns_attrs)
|
||||
|
@ -302,7 +297,6 @@ class Epp::EppDomain < Domain
|
|||
end
|
||||
|
||||
return pt if pt
|
||||
|
||||
if Setting.transfer_wait_time > 0
|
||||
dt = domain_transfers.create(
|
||||
status: DomainTransfer::PENDING,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue