From 1ec79afb11bf5bca4a5c43ae7a720a8514ec4b36 Mon Sep 17 00:00:00 2001 From: olegphenomenon Date: Tue, 30 Nov 2021 16:15:10 +0200 Subject: [PATCH] updated time of response from truemail --- app/interactions/actions/email_check.rb | 2 +- app/jobs/verify_emails_job.rb | 2 +- config/application.yml.sample | 4 +++- config/initializers/truemail.rb | 12 ++++++++---- config/newrelic.yml | 1 + lib/tasks/verify_email.rake | 2 +- test/tasks/emails/verify_email_task_test.rb | 2 +- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/interactions/actions/email_check.rb b/app/interactions/actions/email_check.rb index d336f314a..8f0c940ce 100644 --- a/app/interactions/actions/email_check.rb +++ b/app/interactions/actions/email_check.rb @@ -5,7 +5,7 @@ module Actions def initialize(email:, validation_eventable:, check_level: nil) @email = email @validation_eventable = validation_eventable - @check_level = check_level || :regex + @check_level = check_level || :mx end def call diff --git a/app/jobs/verify_emails_job.rb b/app/jobs/verify_emails_job.rb index 810ace370..4b9b98fb7 100644 --- a/app/jobs/verify_emails_job.rb +++ b/app/jobs/verify_emails_job.rb @@ -1,7 +1,7 @@ class VerifyEmailsJob < ApplicationJob discard_on StandardError - def perform(contact:, check_level: 'regex') + def perform(contact:, check_level: 'mx') contact_not_found(contact.id) unless contact validate_check_level(check_level) action = Actions::EmailCheck.new(email: contact.email, diff --git a/config/application.yml.sample b/config/application.yml.sample index a0cf9fa9e..006e426fb 100644 --- a/config/application.yml.sample +++ b/config/application.yml.sample @@ -181,7 +181,9 @@ tara_rant_identifier: 'identifier' tara_rant_secret: 'secret' tara_rant_redirect_uri: 'redirect_uri' -default_email_validation_type: 'regex' +default_email_validation_type: 'mx' +default_connection_timeout: '1' +default_response_timeout: '1' epp_sessions_per_registrar: '4' diff --git a/config/initializers/truemail.rb b/config/initializers/truemail.rb index ecab32ced..4c3fbf40a 100644 --- a/config/initializers/truemail.rb +++ b/config/initializers/truemail.rb @@ -15,15 +15,16 @@ Truemail.configure do |config| # config.smtp_error_body_pattern = /regex_pattern/ # Optional parameter. Connection timeout is equal to 2 ms by default. - # config.connection_timeout = 1 + config.connection_timeout = ENV['default_connection_timeout'].to_i # Optional parameter. A SMTP server response timeout is equal to 2 ms by default. - # config.response_timeout = 1 + config.response_timeout = ENV['default_response_timeout'].to_i # Optional parameter. Total of connection attempts. It is equal to 2 by default. # This parameter uses in mx lookup timeout error and smtp request (for cases when # there is one mx server). - config.connection_attempts = 3 + config.connection_attempts = 5 + config.not_rfc_mx_lookup_flow = true # Optional parameter. You can predefine default validation type for # Truemail.validate('email@email.com') call without with-parameter @@ -34,9 +35,12 @@ Truemail.configure do |config| elsif Rails.env.production? config.default_validation_type = :mx else - config.default_validation_type = :regex + config.default_validation_type = :mx end + # config.dns = %w[195.43.87.126 195.43.87.158] + config.dns = ENV['dnssec_resolver_ips'].to_s.strip.split(', ').freeze + # Optional parameter. You can predefine which type of validation will be used for domains. # Also you can skip validation by domain. Available validation types: :regex, :mx, :smtp # This configuration will be used over current or default validation type parameter diff --git a/config/newrelic.yml b/config/newrelic.yml index 7f9f556cf..26bb91844 100644 --- a/config/newrelic.yml +++ b/config/newrelic.yml @@ -34,6 +34,7 @@ common: &default_settings development: <<: *default_settings app_name: Registry (Development) + monitor_mode: false test: <<: *default_settings diff --git a/lib/tasks/verify_email.rake b/lib/tasks/verify_email.rake index 209e19176..9712ec77e 100644 --- a/lib/tasks/verify_email.rake +++ b/lib/tasks/verify_email.rake @@ -11,7 +11,7 @@ namespace :verify_email do SPAM_PROTECT_TIMEOUT = 30.seconds options = { domain_name: nil, - check_level: 'regex', + check_level: 'mx', spam_protect: false, } banner = 'Usage: rake verify_email:check_all -- [options]' diff --git a/test/tasks/emails/verify_email_task_test.rb b/test/tasks/emails/verify_email_task_test.rb index 6a684d3fc..dadec546a 100644 --- a/test/tasks/emails/verify_email_task_test.rb +++ b/test/tasks/emails/verify_email_task_test.rb @@ -112,7 +112,7 @@ class VerifyEmailTaskTest < ActiveJob::TestCase assert_not contact.domains.last.force_delete_scheduled? - 2.times do + 3.times do run_task end