mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 10:19:45 +02:00
Story#105418634 Update Whois body
This commit is contained in:
parent
a5bce57915
commit
a2d039bb2e
2 changed files with 67 additions and 62 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
require "erb"
|
||||||
class WhoisRecord < ActiveRecord::Base
|
class WhoisRecord < ActiveRecord::Base
|
||||||
belongs_to :domain
|
belongs_to :domain
|
||||||
belongs_to :registrar
|
belongs_to :registrar
|
||||||
|
@ -45,8 +46,8 @@ class WhoisRecord < ActiveRecord::Base
|
||||||
h[:registered] = domain.registered_at.try(:to_s, :iso8601)
|
h[:registered] = domain.registered_at.try(:to_s, :iso8601)
|
||||||
h[:changed] = domain.updated_at.try(:to_s, :iso8601)
|
h[:changed] = domain.updated_at.try(:to_s, :iso8601)
|
||||||
h[:expire] = domain.valid_to.try(:to_date).try(:to_s)
|
h[:expire] = domain.valid_to.try(:to_date).try(:to_s)
|
||||||
h[:outzone] = domain.outzone_at.try(:to_s, :iso8601)
|
h[:outzone] = domain.outzone_at.try(:to_date).try(:to_s)
|
||||||
h[:delete] = domain.delete_at.try(:to_s, :iso8601)
|
h[:delete] = domain.delete_at.try(:to_date).try(:to_s)
|
||||||
|
|
||||||
|
|
||||||
h[:registrant] = domain.registrant.name
|
h[:registrant] = domain.registrant.name
|
||||||
|
@ -59,7 +60,7 @@ class WhoisRecord < ActiveRecord::Base
|
||||||
h[:admin_contacts] << {
|
h[:admin_contacts] << {
|
||||||
name: ac.name,
|
name: ac.name,
|
||||||
email: ac.email,
|
email: ac.email,
|
||||||
created_at: ac.created_at.try(:to_s, :iso8601)
|
changed: ac.updated_at.try(:to_s, :iso8601)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
h[:tech_contacts] = []
|
h[:tech_contacts] = []
|
||||||
|
@ -68,7 +69,7 @@ class WhoisRecord < ActiveRecord::Base
|
||||||
h[:tech_contacts] << {
|
h[:tech_contacts] << {
|
||||||
name: tc.name,
|
name: tc.name,
|
||||||
email: tc.email,
|
email: tc.email,
|
||||||
created_at: tc.created_at.try(:to_s, :iso8601)
|
changed: tc.updated_at.try(:to_s, :iso8601)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -91,68 +92,12 @@ class WhoisRecord < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def generated_body
|
def generated_body
|
||||||
<<-EOS
|
template = Rails.root.join("app/views/for_models/whois.erb".freeze)
|
||||||
Estonia .ee Top Level Domain WHOIS server
|
ERB.new(template.read, nil, "-").result.binding
|
||||||
|
|
||||||
Domain:
|
|
||||||
name: #{json['name']}
|
|
||||||
registrant: #{json['registrant']}
|
|
||||||
status: #{json['status']}
|
|
||||||
registered: #{Time.zone.parse(json['registered'])}
|
|
||||||
changed: #{Time.zone.parse(json['updated_at'])}
|
|
||||||
expire: #{Time.zone.parse(json['valid_to'])}
|
|
||||||
outzone:
|
|
||||||
delete:
|
|
||||||
#{contacts_body(json['admin_contacts'], json['tech_contacts'])}
|
|
||||||
Registrar:
|
|
||||||
name: #{json['registrar']}
|
|
||||||
phone: #{json['registrar_phone']}
|
|
||||||
address: #{json['registrar_address']}
|
|
||||||
changed: #{Time.zone.parse(json['registrar_update_at'])}
|
|
||||||
#{nameservers_body(json['nameservers'])}
|
|
||||||
Estonia .ee Top Level Domain WHOIS server
|
|
||||||
More information at http://internet.ee
|
|
||||||
EOS
|
|
||||||
end
|
end
|
||||||
# rubocop:enable Metrics/MethodLength
|
# rubocop:enable Metrics/MethodLength
|
||||||
# rubocop:enable Metrics/AbcSize
|
# rubocop:enable Metrics/AbcSize
|
||||||
|
|
||||||
def contacts_body(admins, techs)
|
|
||||||
admins ||= []
|
|
||||||
techs ||= []
|
|
||||||
|
|
||||||
out = ''
|
|
||||||
out << (admins.size > 1 ? "\nAdministrative contacts" : "\nAdministrative contact")
|
|
||||||
admins.each do |c|
|
|
||||||
out << "\n name: #{c['name']}"
|
|
||||||
out << "\n email: Not Disclosed - Visit www.internet.ee for webbased WHOIS"
|
|
||||||
out << "\n registrar: #{c['registrar']}"
|
|
||||||
out << "\n created: #{Time.zone.parse(c['created_at'])}"
|
|
||||||
out << "\n"
|
|
||||||
end
|
|
||||||
|
|
||||||
out << (techs.size > 1 ? "\nTechnical contacts" : "\nTechnical contact:")
|
|
||||||
techs.each do |c|
|
|
||||||
out << "\n name: #{c['name']}"
|
|
||||||
out << "\n email: Not Disclosed - Visit www.internet.ee for webbased WHOIS"
|
|
||||||
out << "\n registrar: #{c['registrar']}"
|
|
||||||
out << "\n created: #{Time.zone.parse(c['created_at'])}"
|
|
||||||
out << "\n"
|
|
||||||
end
|
|
||||||
out
|
|
||||||
end
|
|
||||||
|
|
||||||
def nameservers_body(nservers)
|
|
||||||
nservers ||= []
|
|
||||||
|
|
||||||
out = "\nName servers:"
|
|
||||||
nservers.each do |ns|
|
|
||||||
out << "\n nserver: #{ns['hostname']}"
|
|
||||||
out << "\n changed: #{Time.zone.parse(ns['updated_at'])}"
|
|
||||||
out << "\n"
|
|
||||||
end
|
|
||||||
out
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_whois_server
|
def update_whois_server
|
||||||
wd = Whois::Record.find_or_initialize_by(name: name)
|
wd = Whois::Record.find_or_initialize_by(name: name)
|
||||||
|
|
60
app/views/for_models/whois.erb
Normal file
60
app/views/for_models/whois.erb
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
Estonia .ee Top Level Domain WHOIS server
|
||||||
|
|
||||||
|
Domain:
|
||||||
|
name: <%= json[:name] %>
|
||||||
|
<%- for st in Array(json[:status]) -%>
|
||||||
|
status: <%= st %>
|
||||||
|
<%- end -%>
|
||||||
|
registered: <%= json[:registered].to_s.tr('T',' ').sub('+', ' +') %>
|
||||||
|
changed: <%= json[:changed].to_s.tr('T',' ').sub('+', ' +') %>
|
||||||
|
expire: <%= json[:expire].to_s.tr('T',' ').sub('+', ' +') %>
|
||||||
|
outzone: <%= json[:outzone].to_s.tr('T',' ').sub('+', ' +') %>
|
||||||
|
delete: <%= json[:delete].to_s.tr('T',' ').sub('+', ' +') %>
|
||||||
|
|
||||||
|
Registrant:
|
||||||
|
name: <%= json[:registrant] %>
|
||||||
|
email: Not Disclosed - Visit www.internet.ee for webbased WHOIS
|
||||||
|
changed: <%= json[:changed].to_s.tr('T',' ').sub('+', ' +') %>
|
||||||
|
|
||||||
|
<%- if json[:admin_contacts].present? -%>
|
||||||
|
Administrative contact
|
||||||
|
<%- for contact in json[:admin_contacts] -%>
|
||||||
|
name: <%= contact[:name] %>
|
||||||
|
email: Not Disclosed - Visit www.internet.ee for webbased WHOIS
|
||||||
|
changed: <%= contact[:changed].to_s.tr('T',' ').sub('+', ' +') %>
|
||||||
|
<%- end -%>
|
||||||
|
|
||||||
|
<%- end -%>
|
||||||
|
<% if json[:tech_contacts].present? %>
|
||||||
|
Technical contact:
|
||||||
|
<%- for contact in json[:admin_contacts] -%>
|
||||||
|
name: <%= contact[:name] %>
|
||||||
|
email: Not Disclosed - Visit www.internet.ee for webbased WHOIS
|
||||||
|
changed: <%= contact[:changed].to_s.tr('T',' ').sub('+', ' +') %>
|
||||||
|
<%- end -%>
|
||||||
|
|
||||||
|
<%- end -%>
|
||||||
|
Registrar:
|
||||||
|
name: <%= json[:registrar] %>
|
||||||
|
url: <%= json[:registrar_url] %>
|
||||||
|
phone: <%= json[:registrar_phone] %>
|
||||||
|
changed: <%= json[:registrar_changed].to_s.tr('T',' ').sub('+', ' +') %>
|
||||||
|
|
||||||
|
<%- if json[:nameservers].present? -%>
|
||||||
|
Name servers:
|
||||||
|
<%- for server in json[:nameservers] -%>
|
||||||
|
nserver: <%= server %>
|
||||||
|
<%- end -%>
|
||||||
|
changed: <%= json[:nameservers_changed].to_s.tr('T',' ').sub('+', ' +') %>
|
||||||
|
|
||||||
|
<%- end -%>
|
||||||
|
<%- if json[:dnssec_keys].present? -%>
|
||||||
|
DNSSEC:
|
||||||
|
<%- for key in json[:dnssec_keys] -%>
|
||||||
|
dnskey: <%= key %>
|
||||||
|
<%- end -%>
|
||||||
|
changed: <%= json[:dnssec_changed].to_s.tr('T',' ').sub('+', ' +') %>
|
||||||
|
|
||||||
|
<%- end -%>
|
||||||
|
Estonia .ee Top Level Domain WHOIS server
|
||||||
|
More information at http://internet.ee
|
Loading…
Add table
Add a link
Reference in a new issue