mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 08:52:04 +02:00
parent
59db269240
commit
d695d95ad7
15 changed files with 184 additions and 30 deletions
26
app/models/concerns/contact/disclosable.rb
Normal file
26
app/models/concerns/contact/disclosable.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Concerns
|
||||
module Contact
|
||||
module Disclosable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
attr_accessor :disclosable_attributes
|
||||
end
|
||||
|
||||
included do
|
||||
self.disclosable_attributes = %w[name email]
|
||||
validate :validate_disclosed_attributes
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def validate_disclosed_attributes
|
||||
return if disclosed_attributes.empty?
|
||||
|
||||
has_undisclosable_attributes = (disclosed_attributes - self.class.disclosable_attributes)
|
||||
.any?
|
||||
errors.add(:disclosed_attributes, :invalid) if has_undisclosable_attributes
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -4,6 +4,7 @@ class Contact < ActiveRecord::Base
|
|||
include UserEvents
|
||||
include Concerns::Contact::Transferable
|
||||
include Concerns::Contact::Identical
|
||||
include Concerns::Contact::Disclosable
|
||||
|
||||
belongs_to :original, class_name: self.name
|
||||
belongs_to :registrar, required: true
|
||||
|
|
|
@ -52,22 +52,18 @@ class WhoisRecord < ActiveRecord::Base
|
|||
|
||||
h[:email] = registrant.email
|
||||
h[:registrant_changed] = registrant.updated_at.try(:to_s, :iso8601)
|
||||
h[:registrant_disclosed_attributes] = registrant.disclosed_attributes
|
||||
|
||||
h[:admin_contacts] = []
|
||||
domain.admin_contacts.each do |ac|
|
||||
h[:admin_contacts] << {
|
||||
name: ac.name,
|
||||
email: ac.email,
|
||||
changed: ac.updated_at.try(:to_s, :iso8601)
|
||||
}
|
||||
|
||||
domain.admin_contacts.each do |contact|
|
||||
h[:admin_contacts] << contact_json_hash(contact)
|
||||
end
|
||||
|
||||
h[:tech_contacts] = []
|
||||
domain.tech_contacts.each do |tc|
|
||||
h[:tech_contacts] << {
|
||||
name: tc.name,
|
||||
email: tc.email,
|
||||
changed: tc.updated_at.try(:to_s, :iso8601)
|
||||
}
|
||||
|
||||
domain.tech_contacts.each do |contact|
|
||||
h[:tech_contacts] << contact_json_hash(contact)
|
||||
end
|
||||
|
||||
# update registar triggers when adding new attributes
|
||||
|
@ -109,4 +105,13 @@ class WhoisRecord < ActiveRecord::Base
|
|||
def disclaimer_text
|
||||
Setting.registry_whois_disclaimer
|
||||
end
|
||||
|
||||
def contact_json_hash(contact)
|
||||
{
|
||||
name: contact.name,
|
||||
email: contact.email,
|
||||
changed: contact.updated_at.try(:to_s, :iso8601),
|
||||
disclosed_attributes: contact.disclosed_attributes,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue