Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPhenomenon committed Aug 22, 2023
1 parent 9f4d4ec commit 64fb5c6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/interactions/actions/simple_mail_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ module SimpleMailValidator
extend self

def run(email:, level:)
local_part, domain = email.split('@')
decoded_domain = Addressable::IDNA.to_unicode(domain)
email = "#{local_part}@#{decoded_domain}"
email = decode_email_punycode(email)

result = truemail_validate(email: email, level: level)
result = validate_for_a_and_aaaa_records(email) if !result && level == :mx
Expand Down Expand Up @@ -36,6 +34,12 @@ def output_a_and_aaaa_validation_results(email:, result:, type:)
logger.info "Validated #{type} record for #{email}. Validation result - #{result}"
end

def decode_email_punycode(email)
local_part, domain = email.split('@')
decoded_domain = Addressable::IDNA.to_unicode(domain)
"#{local_part}@#{decoded_domain}"
end

def logger
@logger ||= Rails.logger
end
Expand Down

0 comments on commit 64fb5c6

Please sign in to comment.