mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 02:05:57 +02:00
fixed multiple domains updating
This commit is contained in:
parent
e2a085761f
commit
0f18c1f93f
1 changed files with 8 additions and 15 deletions
|
@ -175,33 +175,26 @@ class Registrar < ApplicationRecord
|
||||||
|
|
||||||
def add_nameservers(new_attributes, domains: [])
|
def add_nameservers(new_attributes, domains: [])
|
||||||
transaction do
|
transaction do
|
||||||
domain_scope = domains.dup
|
|
||||||
domain_list = []
|
|
||||||
failed_list = []
|
|
||||||
|
|
||||||
return if domains.empty?
|
return if domains.empty?
|
||||||
|
|
||||||
domain_list_processing(domain_scope, new_attributes, domain_list, failed_list)
|
approved_list = domain_list_processing(domains: domains, new_attributes: new_attributes)
|
||||||
|
|
||||||
self.domains.where(name: domain_list).find_each(&:update_whois_record) if domain_list.any?
|
self.domains.where(name: approved_list).find_each(&:update_whois_record) if approved_list.any?
|
||||||
[domain_list.uniq.sort, (domain_scope + failed_list).uniq.sort]
|
[approved_list.uniq.sort, (domains - approved_list).uniq.sort]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def domain_list_processing(domains, new_attributes, domain_list, failed_list)
|
def domain_list_processing(domains:, new_attributes:)
|
||||||
|
approved_list = []
|
||||||
domains.each do |domain_name|
|
domains.each do |domain_name|
|
||||||
domain = self.domains.find_by('name = ? OR name_puny = ?', domain_name, domain_name)
|
domain = self.domains.find_by('name = ? OR name_puny = ?', domain_name, domain_name)
|
||||||
|
|
||||||
if domain.blank? || domain_not_updatable?(hostname: new_attributes[:hostname], domain: domain)
|
next if domain.blank? || domain_not_updatable?(hostname: new_attributes[:hostname], domain: domain)
|
||||||
failed_list << domain_name
|
|
||||||
next
|
|
||||||
end
|
|
||||||
|
|
||||||
create_nameserver(domain, new_attributes)
|
create_nameserver(domain, new_attributes)
|
||||||
|
approved_list << domain_name
|
||||||
domains.delete_if { |i| i == domain.name || i == domain.name_puny }
|
|
||||||
domain_list << domain_name
|
|
||||||
end
|
end
|
||||||
|
approved_list
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_nameserver(domain, attributes)
|
def create_nameserver(domain, attributes)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue