mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 05:05:45 +02:00
Fix some CC issues
This commit is contained in:
parent
221e4ba578
commit
7caa544c83
8 changed files with 50 additions and 53 deletions
|
@ -40,7 +40,8 @@ module Epp
|
||||||
authorize!(:update, @domain, @password)
|
authorize!(:update, @domain, @password)
|
||||||
|
|
||||||
registrar_id = current_user.registrar.id
|
registrar_id = current_user.registrar.id
|
||||||
update_params = ::Deserializers::Xml::DomainUpdate.new(params[:parsed_frame], registrar_id).call
|
update_params = ::Deserializers::Xml::DomainUpdate.new(params[:parsed_frame],
|
||||||
|
registrar_id).call
|
||||||
action = Actions::DomainUpdate.new(@domain, update_params, false)
|
action = Actions::DomainUpdate.new(@domain, update_params, false)
|
||||||
if action.call
|
if action.call
|
||||||
pending = @domain.epp_pending_update.present?
|
pending = @domain.epp_pending_update.present?
|
||||||
|
|
|
@ -24,13 +24,10 @@ module Domains
|
||||||
user = ApiUser.find(domain.pending_json['current_user_id'])
|
user = ApiUser.find(domain.pending_json['current_user_id'])
|
||||||
frame = domain.pending_json['frame'] ? domain.pending_json['frame'].with_indifferent_access : {}
|
frame = domain.pending_json['frame'] ? domain.pending_json['frame'].with_indifferent_access : {}
|
||||||
|
|
||||||
#self.statuses.delete(DomainStatus::PENDING_UPDATE)
|
|
||||||
domain.upid = user.registrar.id if user.registrar
|
domain.upid = user.registrar.id if user.registrar
|
||||||
domain.up_date = Time.zone.now
|
domain.up_date = Time.zone.now
|
||||||
|
|
||||||
Actions::DomainUpdate.new(domain, frame, true).call
|
Actions::DomainUpdate.new(domain, frame, true).call
|
||||||
|
|
||||||
#save!
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -69,7 +69,7 @@ module Actions
|
||||||
attrs = []
|
attrs = []
|
||||||
params[:admin_domain_contacts_attributes].each do |c|
|
params[:admin_domain_contacts_attributes].each do |c|
|
||||||
contact = Contact.find_by(code: c)
|
contact = Contact.find_by(code: c)
|
||||||
domain.add_epp_error('2303', 'contact', c, %i[domain_contacts not_found]) unless contact.present?
|
domain.add_epp_error('2303', 'contact', c, %i[domain_contacts not_found]) if contact.blank?
|
||||||
attrs << { contact_id: contact.id, contact_code_cache: contact.code } if contact
|
attrs << { contact_id: contact.id, contact_code_cache: contact.code } if contact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ module Actions
|
||||||
attrs = []
|
attrs = []
|
||||||
params[:tech_domain_contacts_attributes].each do |c|
|
params[:tech_domain_contacts_attributes].each do |c|
|
||||||
contact = Contact.find_by(code: c)
|
contact = Contact.find_by(code: c)
|
||||||
domain.add_epp_error('2303', 'contact', c, %i[domain_contacts not_found]) unless contact.present?
|
domain.add_epp_error('2303', 'contact', c, %i[domain_contacts not_found]) if contact.blank?
|
||||||
attrs << { contact_id: contact.id, contact_code_cache: contact.code } if contact
|
attrs << { contact_id: contact.id, contact_code_cache: contact.code } if contact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -104,9 +104,9 @@ module Actions
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
domain.registrar.debit!({ sum: @domain_pricelist.price.amount, price: @domain_pricelist,
|
domain.registrar.debit!(sum: @domain_pricelist.price.amount, price: @domain_pricelist,
|
||||||
description: "#{I18n.t('create')} #{domain.name}",
|
description: "#{I18n.t('create')} #{domain.name}",
|
||||||
activity_type: AccountActivity::CREATE })
|
activity_type: AccountActivity::CREATE)
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_auction_and_disputes
|
def process_auction_and_disputes
|
||||||
|
|
|
@ -33,7 +33,10 @@ module Actions
|
||||||
def assign_new_registrant
|
def assign_new_registrant
|
||||||
return unless params[:registrant]
|
return unless params[:registrant]
|
||||||
|
|
||||||
domain.add_epp_error('2306', nil, nil, %i[registrant cannot_be_missing]) unless params[:registrant][:code]
|
unless params[:registrant][:code]
|
||||||
|
domain.add_epp_error('2306', nil, nil, %i[registrant cannot_be_missing])
|
||||||
|
end
|
||||||
|
|
||||||
regt = Registrant.find_by(code: params[:registrant][:code])
|
regt = Registrant.find_by(code: params[:registrant][:code])
|
||||||
if regt.present?
|
if regt.present?
|
||||||
return if domain.registrant == regt
|
return if domain.registrant == regt
|
||||||
|
@ -51,7 +54,10 @@ module Actions
|
||||||
nameservers = []
|
nameservers = []
|
||||||
params[:nameservers].select { |ns| ns[:action] == 'rem' }.each do |ns_attr|
|
params[:nameservers].select { |ns| ns[:action] == 'rem' }.each do |ns_attr|
|
||||||
ns = domain.nameservers.find_by_hash_params(ns_attr.except(:action)).first
|
ns = domain.nameservers.find_by_hash_params(ns_attr.except(:action)).first
|
||||||
domain.add_epp_error('2303', 'hostAttr', ns_attr[:hostname], %i[nameservers not_found]) and break unless ns
|
unless ns
|
||||||
|
domain.add_epp_error('2303', 'hostAttr', ns_attr[:hostname], %i[nameservers not_found])
|
||||||
|
break
|
||||||
|
end
|
||||||
nameservers << { id: ns.id, _destroy: 1 }
|
nameservers << { id: ns.id, _destroy: 1 }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -59,7 +65,7 @@ module Actions
|
||||||
nameservers << ns_attr.except(:action)
|
nameservers << ns_attr.except(:action)
|
||||||
end
|
end
|
||||||
|
|
||||||
return unless nameservers.present?
|
return if nameservers.blank?
|
||||||
|
|
||||||
domain.nameservers_attributes = nameservers
|
domain.nameservers_attributes = nameservers
|
||||||
end
|
end
|
||||||
|
@ -95,7 +101,8 @@ module Actions
|
||||||
contacts = params[:contacts].select { |c| c[:type] == 'admin' }
|
contacts = params[:contacts].select { |c| c[:type] == 'admin' }
|
||||||
|
|
||||||
if contacts.present? && domain.admin_change_prohibited?
|
if contacts.present? && domain.admin_change_prohibited?
|
||||||
domain.add_epp_error('2304', 'admin', DomainStatus::SERVER_ADMIN_CHANGE_PROHIBITED, I18n.t(:object_status_prohibits_operation))
|
domain.add_epp_error('2304', 'admin', DomainStatus::SERVER_ADMIN_CHANGE_PROHIBITED,
|
||||||
|
I18n.t(:object_status_prohibits_operation))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -109,10 +116,11 @@ module Actions
|
||||||
end
|
end
|
||||||
|
|
||||||
contacts.select { |c| c[:action] == 'add' }.each do |c|
|
contacts.select { |c| c[:action] == 'add' }.each do |c|
|
||||||
contact = Epp::Contact.find_by_epp_code(c[:code])
|
contact = Epp::Contact.find_by(code: c[:code])
|
||||||
if contact.present?
|
if contact.present?
|
||||||
if contact.org?
|
if contact.org?
|
||||||
domain.add_epp_error('2306', 'contact', c[:code], %i[domain_contacts admin_contact_can_be_only_private_person])
|
domain.add_epp_error('2306', 'contact', c[:code],
|
||||||
|
%i[domain_contacts admin_contact_can_be_only_private_person])
|
||||||
else
|
else
|
||||||
props << { contact_id: contact.id, contact_code_cache: contact.code }
|
props << { contact_id: contact.id, contact_code_cache: contact.code }
|
||||||
end
|
end
|
||||||
|
@ -121,7 +129,7 @@ module Actions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return unless props.present?
|
return if props.blank?
|
||||||
|
|
||||||
domain.admin_domain_contacts_attributes = props
|
domain.admin_domain_contacts_attributes = props
|
||||||
end
|
end
|
||||||
|
@ -133,7 +141,8 @@ module Actions
|
||||||
contacts = params[:contacts].select { |c| c[:type] == 'tech' }
|
contacts = params[:contacts].select { |c| c[:type] == 'tech' }
|
||||||
|
|
||||||
if contacts.present? && domain.tech_change_prohibited?
|
if contacts.present? && domain.tech_change_prohibited?
|
||||||
domain.add_epp_error('2304', 'tech', DomainStatus::SERVER_TECH_CHANGE_PROHIBITED, I18n.t(:object_status_prohibits_operation))
|
domain.add_epp_error('2304', 'tech', DomainStatus::SERVER_TECH_CHANGE_PROHIBITED,
|
||||||
|
I18n.t(:object_status_prohibits_operation))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -147,7 +156,7 @@ module Actions
|
||||||
end
|
end
|
||||||
|
|
||||||
contacts.select { |c| c[:action] == 'add' }.each do |c|
|
contacts.select { |c| c[:action] == 'add' }.each do |c|
|
||||||
contact = Epp::Contact.find_by_epp_code(c[:code])
|
contact = Epp::Contact.find_by(code: c[:code])
|
||||||
if contact.present?
|
if contact.present?
|
||||||
props << { contact_id: contact.id, contact_code_cache: contact.code }
|
props << { contact_id: contact.id, contact_code_cache: contact.code }
|
||||||
else
|
else
|
||||||
|
@ -155,7 +164,7 @@ module Actions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return unless props.present?
|
return if props.blank?
|
||||||
|
|
||||||
domain.tech_domain_contacts_attributes = props
|
domain.tech_domain_contacts_attributes = props
|
||||||
end
|
end
|
||||||
|
@ -203,10 +212,12 @@ module Actions
|
||||||
Dispute.close_by_domain(domain.name)
|
Dispute.close_by_domain(domain.name)
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
domain.add_epp_error('2202', nil, nil, 'Invalid authorization information; invalid reserved>pw value')
|
domain.add_epp_error('2202', nil, nil,
|
||||||
|
'Invalid authorization information; invalid reserved>pw value')
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
domain.add_epp_error('2304', nil, nil, 'Required parameter missing; reservedpw element required for dispute domains')
|
domain.add_epp_error('2304', nil, nil, "Required parameter missing; reservedpw element " \
|
||||||
|
'required for dispute domains')
|
||||||
end
|
end
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|
|
@ -129,26 +129,6 @@ class Epp::Domain < Domain
|
||||||
self.legal_document_id = doc.id
|
self.legal_document_id = doc.id
|
||||||
end
|
end
|
||||||
|
|
||||||
def apply_pending_update!
|
|
||||||
preclean_pendings
|
|
||||||
user = ApiUser.find(pending_json['current_user_id'])
|
|
||||||
frame = pending_json['frame'] ? pending_json['frame'].with_indifferent_access : {}
|
|
||||||
|
|
||||||
self.statuses.delete(DomainStatus::PENDING_UPDATE)
|
|
||||||
self.upid = user.registrar.id if user.registrar
|
|
||||||
self.up_date = Time.zone.now
|
|
||||||
|
|
||||||
return unless Actions::DomainUpdate.new(self, frame, true).call
|
|
||||||
|
|
||||||
clean_pendings!
|
|
||||||
|
|
||||||
save!
|
|
||||||
|
|
||||||
WhoisRecord.find_by(domain_id: id).save # need to reload model
|
|
||||||
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
def apply_pending_delete!
|
def apply_pending_delete!
|
||||||
preclean_pendings
|
preclean_pendings
|
||||||
statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION)
|
statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION)
|
||||||
|
|
|
@ -3,9 +3,10 @@ module Deserializers
|
||||||
class DnssecKey
|
class DnssecKey
|
||||||
attr_reader :frame, :dsa
|
attr_reader :frame, :dsa
|
||||||
|
|
||||||
KEY_INTERFACE = { flags: 'flags', protocol: 'protocol', alg: 'alg', public_key: 'pubKey' }
|
KEY_INTERFACE = { flags: 'flags', protocol: 'protocol', alg: 'alg',
|
||||||
|
public_key: 'pubKey' }.freeze
|
||||||
DS_INTERFACE = { ds_key_tag: 'keyTag', ds_alg: 'alg', ds_digest_type: 'digestType',
|
DS_INTERFACE = { ds_key_tag: 'keyTag', ds_alg: 'alg', ds_digest_type: 'digestType',
|
||||||
ds_digest: 'digest' }
|
ds_digest: 'digest' }.freeze
|
||||||
|
|
||||||
def initialize(frame, dsa)
|
def initialize(frame, dsa)
|
||||||
@frame = frame
|
@frame = frame
|
||||||
|
|
|
@ -14,8 +14,9 @@ module Deserializers
|
||||||
|
|
||||||
def call
|
def call
|
||||||
obj = { domain: frame.css('name')&.text, registrant: registrant, contacts: contacts,
|
obj = { domain: frame.css('name')&.text, registrant: registrant, contacts: contacts,
|
||||||
auth_info: if_present('authInfo > pw'), nameservers: nameservers, dns_keys: dns_keys,
|
auth_info: if_present('authInfo > pw'), nameservers: nameservers,
|
||||||
registrar_id: registrar, statuses: statuses, reserved_pw: if_present('reserved > pw') }
|
registrar_id: registrar, statuses: statuses, dns_keys: dns_keys,
|
||||||
|
reserved_pw: if_present('reserved > pw') }
|
||||||
|
|
||||||
obj.reject { |_key, val| val.blank? }
|
obj.reject { |_key, val| val.blank? }
|
||||||
end
|
end
|
||||||
|
@ -23,7 +24,8 @@ module Deserializers
|
||||||
def registrant
|
def registrant
|
||||||
return if frame.css('chg > registrant').blank?
|
return if frame.css('chg > registrant').blank?
|
||||||
|
|
||||||
{ code: frame.css('chg > registrant').text, verified: frame.css('chg > registrant').attr('verified').to_s.downcase == 'yes' }
|
{ code: frame.css('chg > registrant').text,
|
||||||
|
verified: frame.css('chg > registrant').attr('verified').to_s.downcase == 'yes' }
|
||||||
end
|
end
|
||||||
|
|
||||||
def contacts
|
def contacts
|
||||||
|
@ -36,7 +38,7 @@ module Deserializers
|
||||||
contacts << { code: c.text, type: c['type'], action: 'rem' }
|
contacts << { code: c.text, type: c['type'], action: 'rem' }
|
||||||
end
|
end
|
||||||
|
|
||||||
contacts.present? ? contacts : nil
|
contacts.presence
|
||||||
end
|
end
|
||||||
|
|
||||||
def nameservers
|
def nameservers
|
||||||
|
@ -53,7 +55,7 @@ module Deserializers
|
||||||
nameservers << nsrv
|
nameservers << nsrv
|
||||||
end
|
end
|
||||||
|
|
||||||
nameservers.present? ? nameservers : nil
|
nameservers.presence
|
||||||
end
|
end
|
||||||
|
|
||||||
def dns_keys
|
def dns_keys
|
||||||
|
@ -62,18 +64,23 @@ module Deserializers
|
||||||
removed = ::Deserializers::Xml::DnssecKeys.new(frame.css('rem')).call
|
removed = ::Deserializers::Xml::DnssecKeys.new(frame.css('rem')).call
|
||||||
removed.each { |k| k[:action] = 'rem' }
|
removed.each { |k| k[:action] = 'rem' }
|
||||||
|
|
||||||
return unless (added + removed).present?
|
return if (added + removed).blank?
|
||||||
|
|
||||||
added + removed
|
added + removed
|
||||||
end
|
end
|
||||||
|
|
||||||
def statuses
|
def statuses
|
||||||
return unless frame.css('status').present?
|
return if frame.css('status').blank?
|
||||||
|
|
||||||
statuses = []
|
statuses = []
|
||||||
|
|
||||||
frame.css('add > status').each { |entry| statuses << { status: entry.attr('s').to_s, action: 'add' } }
|
frame.css('add > status').each do |e|
|
||||||
frame.css('rem > status').each { |entry| statuses << { status: entry.attr('s').to_s, action: 'rem' } }
|
statuses << { status: e.attr('s').to_s, action: 'add' }
|
||||||
|
end
|
||||||
|
|
||||||
|
frame.css('rem > status').each do |e|
|
||||||
|
statuses << { status: e.attr('s').to_s, action: 'rem' }
|
||||||
|
end
|
||||||
|
|
||||||
statuses
|
statuses
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Deserializers
|
||||||
{
|
{
|
||||||
hostname: frame.css('hostName').text,
|
hostname: frame.css('hostName').text,
|
||||||
ipv4: frame.css('hostAddr[ip="v4"]').map(&:text).compact,
|
ipv4: frame.css('hostAddr[ip="v4"]').map(&:text).compact,
|
||||||
ipv6: frame.css('hostAddr[ip="v6"]').map(&:text).compact
|
ipv6: frame.css('hostAddr[ip="v6"]').map(&:text).compact,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue