mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 22:54:47 +02:00
Reserved: Respect other domain statuses
This commit is contained in:
parent
0998ada2fc
commit
4efd94a90b
2 changed files with 15 additions and 8 deletions
|
@ -47,8 +47,10 @@ class UpdateWhoisRecordJob < Que::Job
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_reserved(name)
|
def delete_reserved(name)
|
||||||
Domain.where(name: name).any?
|
Whois::Record.where(name: name).each do |r|
|
||||||
Whois::Record.where(name: name).delete_all
|
r.json['status'] = r.json['Reserved'].delete_if { |status| status == 'Reserved' }
|
||||||
|
r.json['status'].blank? ? r.destroy : r.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_blocked(name)
|
def delete_blocked(name)
|
||||||
|
|
|
@ -51,17 +51,22 @@ class ReservedDomain < ApplicationRecord
|
||||||
return if Domain.where(name: name).any?
|
return if Domain.where(name: name).any?
|
||||||
|
|
||||||
wr = Whois::Record.find_or_initialize_by(name: name)
|
wr = Whois::Record.find_or_initialize_by(name: name)
|
||||||
wr.json = @json = generate_json # we need @json to bind to class
|
wr.json = @json = generate_json(wr) # we need @json to bind to class
|
||||||
wr.save
|
wr.save
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_method :update_whois_record, :generate_data
|
alias_method :update_whois_record, :generate_data
|
||||||
|
|
||||||
def generate_json
|
def generate_json(record)
|
||||||
h = HashWithIndifferentAccess.new
|
h = HashWithIndifferentAccess.new(name: name, status: ['Reserved'])
|
||||||
h[:name] = self.name
|
return h if record.json.blank?
|
||||||
h[:status] = ['Reserved']
|
|
||||||
h
|
status_arr = (record.json['status'] ||= [])
|
||||||
|
return record.json if status_arr.include? 'Reserved'
|
||||||
|
|
||||||
|
status_arr.push('Reserved')
|
||||||
|
record.json['status'] = status_arr
|
||||||
|
record.json
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_data
|
def remove_data
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue