mirror of
https://github.com/internetee/registry.git
synced 2025-08-06 09:45:11 +02:00
Story#113066359 - all whois generation of domain and reserved/blocked domain is async + domain destroy removes whois async
This commit is contained in:
parent
ca037092d3
commit
93d765dea2
5 changed files with 66 additions and 47 deletions
|
@ -1,16 +1,52 @@
|
|||
class UpdateWhoisRecordJob < Que::Job
|
||||
|
||||
def run(ids, type)
|
||||
def run(names, type)
|
||||
klass = case type
|
||||
when 'reserved'then ReservedDomain
|
||||
when 'blocked' then BlockedDomain
|
||||
else Domain
|
||||
when 'domain' then Domain
|
||||
end
|
||||
|
||||
ids.each do |id|
|
||||
record = klass.find_by(id: id)
|
||||
next unless record
|
||||
record.update_whois_record
|
||||
Array(names).each do |name|
|
||||
record = klass.find_by(name: name)
|
||||
if record
|
||||
send "update_#{type}", record
|
||||
else
|
||||
send "delete_#{type}", name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def update_domain(domain)
|
||||
domain.whois_record ? domain.whois_record.save : domain.create_whois_record
|
||||
end
|
||||
|
||||
def update_reserved(record)
|
||||
record.generate_data
|
||||
end
|
||||
|
||||
def update_blocked(record)
|
||||
update_reserved(record)
|
||||
end
|
||||
|
||||
|
||||
# 1. deleting own
|
||||
# 2. trying to regenerate reserved in order domain is still in the list
|
||||
def delete_domain(name)
|
||||
WhoisRecord.where(name: name).destroy_all
|
||||
|
||||
BlockedDomain.find_by(name: name).try(:generate_data)
|
||||
ReservedDomain.find_by(name: name).try(:generate_data)
|
||||
end
|
||||
|
||||
def delete_reserved(name)
|
||||
Domain.where(name: name).any?
|
||||
Whois::Record.where(name: name).delete_all
|
||||
end
|
||||
|
||||
def delete_blocked(name)
|
||||
delete_reserved(name)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue