fixes after review

This commit is contained in:
dinsmol 2021-09-27 16:45:08 +03:00
parent 8365bede3f
commit c1a35cb468

View file

@ -8,12 +8,12 @@ module Whois
def execute def execute
::PaperTrail.request.whodunnit = "job - #{self.class.name} - #{type}" ::PaperTrail.request.whodunnit = "job - #{self.class.name} - #{type}"
klass = determine_class collection = determine_collection
Array(names).each do |name| Array(names).each do |name|
record = find_record(klass, name) record = find_record(collection, name)
if record if record
Whois::UpdateRecord.run(record: { klass: klass.to_s, id: record.id, type: type }) Whois::UpdateRecord.run(record: { klass: collection.to_s, id: record.id, type: type })
else else
Whois::DeleteRecord.run(name: name, type: type) Whois::DeleteRecord.run(name: name, type: type)
end end
@ -22,7 +22,7 @@ module Whois
private private
def determine_class def determine_collection
case type case type
when 'reserved' then ReservedDomain when 'reserved' then ReservedDomain
when 'blocked' then BlockedDomain when 'blocked' then BlockedDomain
@ -32,11 +32,11 @@ module Whois
end end
end end
def find_record(klass, name) def find_record(collection, name)
if klass == Dispute.active if collection == Dispute.active
klass.find_by(domain_name: name) collection.find_by(domain_name: name)
else else
klass == DNS::Zone ? klass.find_by(origin: name) : klass.find_by(name: name) collection == DNS::Zone ? collection.find_by(origin: name) : collection.find_by(name: name)
end end
end end
end end