mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 08:43:37 +02:00
Story#105418634 Update Whois json
This commit is contained in:
parent
a3272fab43
commit
0c06cec8e3
1 changed files with 32 additions and 26 deletions
|
@ -36,50 +36,56 @@ class WhoisRecord < ActiveRecord::Base
|
||||||
return h if domain.blank?
|
return h if domain.blank?
|
||||||
|
|
||||||
status_map = {
|
status_map = {
|
||||||
'ok' => 'ok (paid and in zone)'
|
'ok' => 'ok (paid and in zone)'
|
||||||
}
|
}
|
||||||
|
|
||||||
@disclosed = []
|
@disclosed = []
|
||||||
h[:name] = domain.name
|
h[:name] = domain.name
|
||||||
h[:registrant] = domain.registrant.name
|
h[:status] = domain.statuses.map { |x| status_map[x] || x }
|
||||||
h[:status] = domain.statuses.map { |x| status_map[x] || x }.join(', ')
|
|
||||||
h[:registered] = domain.registered_at.try(:to_s, :iso8601)
|
h[:registered] = domain.registered_at.try(:to_s, :iso8601)
|
||||||
h[:updated_at] = domain.updated_at.try(:to_s, :iso8601)
|
h[:changed] = domain.updated_at.try(:to_s, :iso8601)
|
||||||
h[:valid_to] = domain.valid_to.try(:to_s, :iso8601)
|
h[:expire] = domain.valid_to.try(:to_date).try(:to_s)
|
||||||
|
h[:outzone] = nil
|
||||||
|
h[:delete] = domain.force_delete_at.try(:to_s, :iso8601)
|
||||||
|
|
||||||
# update registar triggers when adding new attributes
|
|
||||||
h[:registrar] = domain.registrar.name
|
h[:registrant] = domain.registrant.name
|
||||||
h[:registrar_phone] = domain.registrar.phone
|
h[:registrant_email] = domain.registrant.email
|
||||||
h[:registrar_address] = domain.registrar.address
|
h[:changed] = domain.registrant.updated_at.try(:to_s, :iso8601)
|
||||||
h[:registrar_update_at] = domain.registrar.updated_at.try(:to_s, :iso8601)
|
|
||||||
|
|
||||||
h[:admin_contacts] = []
|
h[:admin_contacts] = []
|
||||||
domain.admin_contacts.each do |ac|
|
domain.admin_contacts.each do |ac|
|
||||||
@disclosed << [:email, ac.email]
|
@disclosed << [:email, ac.email]
|
||||||
h[:admin_contacts] << {
|
h[:admin_contacts] << {
|
||||||
name: ac.name,
|
name: ac.name,
|
||||||
email: ac.email,
|
email: ac.email,
|
||||||
registrar: ac.registrar.name,
|
created_at: ac.created_at.try(:to_s, :iso8601)
|
||||||
created_at: ac.created_at.try(:to_s, :iso8601)
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
h[:tech_contacts] = []
|
h[:tech_contacts] = []
|
||||||
domain.tech_contacts.each do |tc|
|
domain.tech_contacts.each do |tc|
|
||||||
@disclosed << [:email, tc.email]
|
@disclosed << [:email, tc.email]
|
||||||
h[:tech_contacts] << {
|
h[:tech_contacts] << {
|
||||||
name: tc.name,
|
name: tc.name,
|
||||||
email: tc.email,
|
email: tc.email,
|
||||||
registrar: tc.registrar.name,
|
created_at: tc.created_at.try(:to_s, :iso8601)
|
||||||
created_at: tc.created_at.try(:to_s, :iso8601)
|
|
||||||
}
|
|
||||||
end
|
|
||||||
h[:nameservers] = []
|
|
||||||
domain.nameservers.each do |ns|
|
|
||||||
h[:nameservers] << {
|
|
||||||
hostname: ns.hostname,
|
|
||||||
updated_at: ns.updated_at.try(:to_s, :iso8601)
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# update registar triggers when adding new attributes
|
||||||
|
h[:registrar] = domain.registrar.name
|
||||||
|
h[:registrar_url] = domain.registrar.url
|
||||||
|
h[:registrar_phone] = domain.registrar.phone
|
||||||
|
h[:registrar_address] = domain.registrar.address
|
||||||
|
h[:registrar_changed] = domain.registrar.updated_at.try(:to_s, :iso8601)
|
||||||
|
|
||||||
|
h[:nameservers] = domain.nameservers.pluck(:hostname).uniq.select(&:present?)
|
||||||
|
h[:nameservers_changed] = domain.nameservers.pluck(:updated_at).max.try(:to_s, :iso8601)
|
||||||
|
|
||||||
|
h[:dnssec_keys] = domain.dnskeys.map{|key| "#{key.flags} #{key.protocol} #{key.alg} #{key.public_key}" }
|
||||||
|
h[:dnssec_changed] = domain.dnskeys.pluck(:updated_at).max.try(:to_s, :iso8601) rescue nil
|
||||||
|
|
||||||
|
|
||||||
h[:disclosed] = @disclosed
|
h[:disclosed] = @disclosed
|
||||||
h
|
h
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue