Merge pull request #1835 from internetee/1832-registrar-prefix-on-contact-info-and-check-requests

EPP: Find contact without registrar code prefix
This commit is contained in:
Timo Võhmar 2021-02-11 14:03:36 +02:00 committed by GitHub
commit 573f23f874
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 118 additions and 14 deletions

View file

@ -42,17 +42,12 @@ class Epp::Contact < Contact
)
end
def check_availability(codes)
def check_availability(codes, reg:)
codes = [codes] if codes.is_a?(String)
res = []
codes.each do |x|
contact = find_by_epp_code(x)
if contact
res << { code: contact.code, avail: 0, reason: 'in use' }
else
res << { code: x, avail: 1 }
end
codes.map { |c| c.include?(':') ? c : "#{reg}:#{c}" }.map { |c| c.strip.upcase }.each do |x|
c = find_by_epp_code(x)
res << (c ? { code: c.code, avail: 0, reason: 'in use' } : { code: x, avail: 1 })
end
res