Add DomainResource
class to wrap MX lookup/normalize (#32864)
This commit is contained in:
parent
e8b6607ece
commit
62d65504f6
6 changed files with 46 additions and 19 deletions
|
@ -457,13 +457,7 @@ class User < ApplicationRecord
|
|||
|
||||
# Doing this conditionally is not very satisfying, but this is consistent
|
||||
# with the MX records validations we do and keeps the specs tractable.
|
||||
unless self.class.skip_mx_check?
|
||||
Resolv::DNS.open do |dns|
|
||||
dns.timeouts = 5
|
||||
|
||||
records = dns.getresources(domain, Resolv::DNS::Resource::IN::MX).to_a.map { |e| e.exchange.to_s }.compact_blank
|
||||
end
|
||||
end
|
||||
records = DomainResource.new(domain).mx unless self.class.skip_mx_check?
|
||||
|
||||
EmailDomainBlock.requires_approval?(records + [domain], attempt_ip: sign_up_ip)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue