mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 02:35:57 +02:00
Improve readability
This commit is contained in:
parent
a002e87d7c
commit
3d4d669838
2 changed files with 17 additions and 16 deletions
|
@ -87,8 +87,8 @@ class Epp::DomainsController < EppController
|
||||||
def check
|
def check
|
||||||
authorize! :check, Epp::Domain
|
authorize! :check, Epp::Domain
|
||||||
|
|
||||||
names = params[:parsed_frame].css('name').map(&:text)
|
domain_names = params[:parsed_frame].css('name').map(&:text)
|
||||||
@domains = Epp::Domain.check_availability(names)
|
@domains = Epp::Domain.check_availability(domain_names)
|
||||||
render_epp_response '/epp/domains/check'
|
render_epp_response '/epp/domains/check'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -788,31 +788,32 @@ class Epp::Domain < Domain
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_availability(domains)
|
def check_availability(domain_names)
|
||||||
domains = [domains] if domains.is_a?(String)
|
domain_names = [domain_names] if domain_names.is_a?(String)
|
||||||
|
|
||||||
res = []
|
result = []
|
||||||
domains.each do |x|
|
|
||||||
x.strip!
|
domain_names.each do |domain_name|
|
||||||
x.downcase!
|
domain_name.strip!
|
||||||
unless DomainNameValidator.validate_format(x)
|
domain_name.downcase!
|
||||||
res << { name: x, avail: 0, reason: 'invalid format' }
|
unless DomainNameValidator.validate_format(domain_name)
|
||||||
|
result << { name: domain_name, avail: 0, reason: 'invalid format' }
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
if ReservedDomain.pw_for(x).present?
|
if ReservedDomain.pw_for(domain_name).present?
|
||||||
res << { name: x, avail: 0, reason: I18n.t('errors.messages.epp_domain_reserved') }
|
result << { name: domain_name, avail: 0, reason: I18n.t('errors.messages.epp_domain_reserved') }
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
if Domain.find_by_idn x
|
if Domain.find_by_idn domain_name
|
||||||
res << { name: x, avail: 0, reason: 'in use' }
|
result << { name: domain_name, avail: 0, reason: 'in use' }
|
||||||
else
|
else
|
||||||
res << { name: x, avail: 1 }
|
result << { name: domain_name, avail: 1 }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
res
|
result
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue