nameserver replacement: scope only to selected domains

This commit is contained in:
Karl Erik Õunapuu 2020-11-06 15:51:03 +02:00
parent ed7181e060
commit 451e1f79af
No known key found for this signature in database
GPG key ID: C9DD647298A34764
4 changed files with 30 additions and 3 deletions

View file

@ -141,11 +141,13 @@ class Registrar < ApplicationRecord
end
# Audit log is needed, therefore no raw SQL
def replace_nameservers(hostname, new_attributes)
def replace_nameservers(hostname, new_attributes, domains)
transaction do
domain_list = []
nameservers.where(hostname: hostname).find_each do |original_nameserver|
next unless domains.include?(original_nameserver.domain.name_puny) || domains.empty?
new_nameserver = Nameserver.new
new_nameserver.domain = original_nameserver.domain
new_nameserver.attributes = new_attributes