mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 10:19:45 +02:00
Merge pull request #38 from internetee/109367694-epp-id-conventions
109367694 epp id conventions
This commit is contained in:
commit
1e94909c41
11 changed files with 66 additions and 56 deletions
|
@ -67,8 +67,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_log_str(user)
|
def user_log_str(user)
|
||||||
return 'public' if user.nil?
|
user.nil? ? 'public' : user.id_role_username
|
||||||
"#{user.id}-#{user.class}: #{user.username}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def comma_support_for(parent_key, key)
|
def comma_support_for(parent_key, key)
|
||||||
|
|
|
@ -1,23 +1,30 @@
|
||||||
module UserEvents
|
module UserEvents
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
# TODO: remove old
|
included do
|
||||||
# module ClassMethods
|
# EPP requires a server defined creator ID, which should be registrar code if we have one
|
||||||
# def registrar_events(id)
|
def cr_id
|
||||||
# registrar = Registrar.find(id)
|
# try this, rebuild user for registrar before searching history? really?
|
||||||
# return [] unless registrar
|
registrar = self.creator.try(:registrar)
|
||||||
# @events = []
|
if registrar.present? # Did creator return a kind of User that has a registrar?
|
||||||
# registrar.users.each { |user| @events << user_events(user.id) }
|
registrar.code
|
||||||
# registrar.epp_users.each { |user| @events << epp_user_events(user.id) }
|
else
|
||||||
# @events
|
if self.versions.first.try(:object).nil?
|
||||||
# end
|
changes = self.versions.first.try(:object_changes)
|
||||||
|
cr_registrar_id = changes['registrar_id'].second if changes.present?
|
||||||
|
else
|
||||||
|
# untested, expected never to execute
|
||||||
|
cr_registrar_id = self.versions.first.object['registrar_id']
|
||||||
|
end
|
||||||
|
|
||||||
# def user_events(id)
|
if cr_registrar_id.present?
|
||||||
# where(whodunnit: id.to_s)
|
Registrar.find(cr_registrar_id).code
|
||||||
# end
|
else
|
||||||
|
# cr_id optional for domain, but required for contact; but we want something here anyway
|
||||||
|
self.creator_str # Fallback if we failed, maybe we can find a string here
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# def epp_user_events(id)
|
|
||||||
# where(whodunnit: "#{id}-EppUser")
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,32 +22,30 @@ module Versions
|
||||||
|
|
||||||
def creator
|
def creator
|
||||||
return nil if creator_str.blank?
|
return nil if creator_str.blank?
|
||||||
|
creator = user_from_id_role_username creator_str
|
||||||
if creator_str =~ /^\d+-AdminUser:/
|
|
||||||
creator = AdminUser.find_by(id: creator_str)
|
|
||||||
elsif creator_str =~ /^\d+-ApiUser:/
|
|
||||||
creator = ApiUser.find_by(id: creator_str)
|
|
||||||
elsif creator_str =~ /^\d+-api-/ # depricated
|
|
||||||
creator = ApiUser.find_by(id: creator_str)
|
|
||||||
end
|
|
||||||
|
|
||||||
creator.present? ? creator : creator_str
|
creator.present? ? creator : creator_str
|
||||||
end
|
end
|
||||||
|
|
||||||
def updator
|
def updator
|
||||||
return nil if updator_str.blank?
|
return nil if updator_str.blank?
|
||||||
|
updator = user_from_id_role_username updator_str
|
||||||
if updator_str =~ /^\d+-AdminUser:/
|
|
||||||
updator = AdminUser.find_by(id: updator_str)
|
|
||||||
elsif updator_str =~ /^\d+-ApiUser:/
|
|
||||||
updator = ApiUser.find_by(id: updator_str)
|
|
||||||
elsif updator_str =~ /^\d+-api-/ # depricated
|
|
||||||
updator = ApiUser.find_by(id: updator_str)
|
|
||||||
end
|
|
||||||
|
|
||||||
updator.present? ? updator : updator_str
|
updator.present? ? updator : updator_str
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_from_id_role_username(str)
|
||||||
|
user = ApiUser.find_by(id: $1) if str =~ /^(\d+)-(ApiUser:|api-)/
|
||||||
|
unless user.present?
|
||||||
|
user = AdminUser.find_by(id: $1) if str =~ /^(\d+)-AdminUser:/
|
||||||
|
unless user.present?
|
||||||
|
# on import we copied Registrar name, which may eql code
|
||||||
|
registrar = Registrar.find_by(name: str)
|
||||||
|
# assume each registrar has only one user
|
||||||
|
user = registrar.api_users.first if registrar
|
||||||
|
end
|
||||||
|
end
|
||||||
|
user
|
||||||
|
end
|
||||||
|
|
||||||
# callbacks
|
# callbacks
|
||||||
def touch_domain_version
|
def touch_domain_version
|
||||||
domain.try(:touch_with_version)
|
domain.try(:touch_with_version)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
class Contact < ActiveRecord::Base
|
class Contact < ActiveRecord::Base
|
||||||
include Versions # version/contact_version.rb
|
include Versions # version/contact_version.rb
|
||||||
include EppErrors
|
include EppErrors
|
||||||
|
include UserEvents
|
||||||
|
|
||||||
belongs_to :registrar
|
belongs_to :registrar
|
||||||
has_many :domain_contacts
|
has_many :domain_contacts
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# rubocop: disable Metrics/ClassLength
|
# rubocop: disable Metrics/ClassLength
|
||||||
class Domain < ActiveRecord::Base
|
class Domain < ActiveRecord::Base
|
||||||
|
include UserEvents
|
||||||
include Versions # version/domain_version.rb
|
include Versions # version/domain_version.rb
|
||||||
include Statuses
|
include Statuses
|
||||||
has_paper_trail class_name: "DomainVersion", meta: { children: :children_log }
|
has_paper_trail class_name: "DomainVersion", meta: { children: :children_log }
|
||||||
|
|
|
@ -506,7 +506,9 @@ class Epp::Domain < Domain
|
||||||
frame = Nokogiri::XML(pending_json['frame'])
|
frame = Nokogiri::XML(pending_json['frame'])
|
||||||
statuses.delete(DomainStatus::PENDING_UPDATE)
|
statuses.delete(DomainStatus::PENDING_UPDATE)
|
||||||
yield(self) if block_given? # need to skip statuses check here
|
yield(self) if block_given? # need to skip statuses check here
|
||||||
|
self.save
|
||||||
|
|
||||||
|
::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user
|
||||||
return unless update(frame, user, false)
|
return unless update(frame, user, false)
|
||||||
clean_pendings!
|
clean_pendings!
|
||||||
self.deliver_emails = true # turn on email delivery
|
self.deliver_emails = true # turn on email delivery
|
||||||
|
|
|
@ -3,4 +3,9 @@ class User < ActiveRecord::Base
|
||||||
devise :trackable, :timeoutable
|
devise :trackable, :timeoutable
|
||||||
|
|
||||||
attr_accessor :phone
|
attr_accessor :phone
|
||||||
|
|
||||||
|
def id_role_username
|
||||||
|
"#{self.id}-#{self.class}: #{self.username}"
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,5 @@ class ContactVersion < PaperTrail::Version
|
||||||
self.table_name = :log_contacts
|
self.table_name = :log_contacts
|
||||||
self.sequence_name = :log_contacts_id_seq
|
self.sequence_name = :log_contacts_id_seq
|
||||||
|
|
||||||
# include UserEvents
|
|
||||||
|
|
||||||
# scope :deleted, -> { where(event: 'destroy') }
|
# scope :deleted, -> { where(event: 'destroy') }
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,5 @@ class DomainVersion < PaperTrail::Version
|
||||||
self.table_name = :log_domains
|
self.table_name = :log_domains
|
||||||
self.sequence_name = :log_domains_id_seq
|
self.sequence_name = :log_domains_id_seq
|
||||||
|
|
||||||
include UserEvents
|
|
||||||
|
|
||||||
scope :deleted, -> { where(event: 'destroy') }
|
scope :deleted, -> { where(event: 'destroy') }
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,15 +46,15 @@ xml.epp_head do
|
||||||
xml.tag!('contact:email', 'No access')
|
xml.tag!('contact:email', 'No access')
|
||||||
end
|
end
|
||||||
|
|
||||||
xml.tag!('contact:clID', @contact.registrar.try(:name))
|
xml.tag!('contact:clID', @contact.registrar.try(:code))
|
||||||
if @contact.creator.try(:registrar).blank? && Rails.env.test?
|
|
||||||
xml.tag!('contact:crID', 'TEST-CREATOR')
|
xml.tag!('contact:crID', @contact.cr_id)
|
||||||
else
|
|
||||||
xml.tag!('contact:crID', @contact.creator.try(:registrar))
|
|
||||||
end
|
|
||||||
xml.tag!('contact:crDate', @contact.created_at.try(:iso8601))
|
xml.tag!('contact:crDate', @contact.created_at.try(:iso8601))
|
||||||
|
|
||||||
if @contact.updated_at != @contact.created_at
|
if @contact.updated_at != @contact.created_at
|
||||||
xml.tag!('contact:upID', @contact.updator.try(:registrar))
|
upID = @contact.updator.try(:registrar)
|
||||||
|
upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar?
|
||||||
|
xml.tag!('contact:upID', upID) if upID.present? # optional upID
|
||||||
xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601))
|
xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601))
|
||||||
end
|
end
|
||||||
# xml.tag!('contact:trDate', '123') if false
|
# xml.tag!('contact:trDate', '123') if false
|
||||||
|
|
|
@ -36,19 +36,20 @@ xml.epp_head do
|
||||||
|
|
||||||
## TODO Find out what this domain:host is all about
|
## TODO Find out what this domain:host is all about
|
||||||
|
|
||||||
xml.tag!('domain:clID', @domain.registrar_name)
|
xml.tag!('domain:clID', @domain.registrar.code)
|
||||||
|
|
||||||
xml.tag!('domain:crID', @domain.creator.try(:registrar)) if @domain.creator
|
|
||||||
|
|
||||||
|
xml.tag!('domain:crID', @domain.cr_id)
|
||||||
xml.tag!('domain:crDate', @domain.created_at.try(:iso8601))
|
xml.tag!('domain:crDate', @domain.created_at.try(:iso8601))
|
||||||
|
|
||||||
xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) if @domain.updated_at != @domain.created_at
|
if @domain.updated_at != @domain.created_at
|
||||||
|
upID = @domain.updator.try(:registrar)
|
||||||
|
upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar?
|
||||||
|
xml.tag!('domain:upID', upID) if upID.present? # optional upID
|
||||||
|
xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601))
|
||||||
|
end
|
||||||
|
|
||||||
xml.tag!('domain:exDate', @domain.valid_to.try(:iso8601))
|
xml.tag!('domain:exDate', @domain.valid_to.try(:iso8601))
|
||||||
|
|
||||||
# TODO Make domain stampable
|
|
||||||
#xml.tag!('domain:upID', @domain.updated_by)
|
|
||||||
|
|
||||||
# TODO Make domain transferrable
|
# TODO Make domain transferrable
|
||||||
#xml.tag!('domain:trDate', @domain.transferred_at) if @domain.transferred_at
|
#xml.tag!('domain:trDate', @domain.transferred_at) if @domain.transferred_at
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue