mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 07:04:47 +02:00
Reduce complexity for dispute whois generation
This commit is contained in:
parent
b2c2342d7d
commit
b4b43afa56
1 changed files with 4 additions and 12 deletions
|
@ -26,10 +26,6 @@ class Dispute < ApplicationRecord
|
||||||
dispute.update(closed: true) if dispute.present?
|
dispute.update(closed: true) if dispute.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def for_active_domain?
|
|
||||||
Domain.where(name: domain_name).any?
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_expiry_date
|
def set_expiry_date
|
||||||
return if starts_at.blank?
|
return if starts_at.blank?
|
||||||
|
|
||||||
|
@ -44,11 +40,7 @@ class Dispute < ApplicationRecord
|
||||||
return if starts_at > Time.zone.today
|
return if starts_at > Time.zone.today
|
||||||
|
|
||||||
wr = Whois::Record.find_or_initialize_by(name: domain_name)
|
wr = Whois::Record.find_or_initialize_by(name: domain_name)
|
||||||
if for_active_domain?
|
wr.json = generate_json(wr)
|
||||||
wr.json['status'] << 'disputed' unless wr.json['status'].include? 'disputed'
|
|
||||||
else
|
|
||||||
wr.json = generate_json(wr) # we need @json to bind to class
|
|
||||||
end
|
|
||||||
wr.save
|
wr.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -75,12 +67,12 @@ class Dispute < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_json(record)
|
def generate_json(record)
|
||||||
|
status_arr = (record.json['status'] ||= [])
|
||||||
h = HashWithIndifferentAccess.new(name: domain_name, status: ['disputed'])
|
h = HashWithIndifferentAccess.new(name: domain_name, status: ['disputed'])
|
||||||
return h if record.json.blank?
|
return h if record.json.blank?
|
||||||
|
return record.json if status_arr.include? 'disputed'
|
||||||
|
|
||||||
status_arr = (record.json['status'] ||= [])
|
status_arr.push('disputed')
|
||||||
status_arr.push('disputed') unless status_arr.include? 'disputed'
|
|
||||||
|
|
||||||
record.json['status'] = status_arr
|
record.json['status'] = status_arr
|
||||||
record.json
|
record.json
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue