mirror of
https://github.com/internetee/registry.git
synced 2025-07-27 21:16:12 +02:00
Merge pull request #2377 from internetee/fixed-looping-validation
fixed looping validation email
This commit is contained in:
commit
4a973b8624
3 changed files with 25 additions and 18 deletions
|
@ -37,11 +37,12 @@ module Actions
|
||||||
end
|
end
|
||||||
|
|
||||||
def maybe_filtering_old_failed_records
|
def maybe_filtering_old_failed_records
|
||||||
validation_events = contact.validation_events
|
if contact.validation_events.count > 1
|
||||||
return unless validation_events.count > 1
|
contact.validation_events.order!(created_at: :asc)
|
||||||
|
while contact.validation_events.count >= 1
|
||||||
validation_events.order!(created_at: :asc)
|
contact.validation_events.first.destroy
|
||||||
validation_events.first.destroy while validation_events.count >= 1
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def maybe_remove_address
|
def maybe_remove_address
|
||||||
|
|
|
@ -26,21 +26,27 @@ module Actions
|
||||||
Rails.env.test? && check_level == 'smtp' ? :mx : check_level.to_sym
|
Rails.env.test? && check_level == 'smtp' ? :mx : check_level.to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_old_validations(validation_events, minimum_size, check_level)
|
|
||||||
return unless validation_events.count > minimum_size && @check_level == check_level
|
|
||||||
|
|
||||||
validation_events.order!(created_at: :asc)
|
|
||||||
validation_events.first.destroy while validation_events.count > minimum_size
|
|
||||||
end
|
|
||||||
|
|
||||||
def filtering_old_failed_records(result)
|
def filtering_old_failed_records(result)
|
||||||
events = validation_eventable.validation_events
|
if @check_level == "mx" && !result.success && validation_eventable.validation_events.count > 3
|
||||||
|
validation_eventable.validation_events.order!(created_at: :asc)
|
||||||
|
while validation_eventable.validation_events.count > 3
|
||||||
|
validation_eventable.validation_events.first.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
destroy_old_validations(events, ValidationEvent::MX_CHECK, 'mx') unless result.success
|
if @check_level == "mx" && result.success && validation_eventable.validation_events.count > 1
|
||||||
|
validation_eventable.validation_events.order!(created_at: :asc)
|
||||||
|
while validation_eventable.validation_events.count > 1
|
||||||
|
validation_eventable.validation_events.first.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
destroy_old_validations(events, ValidationEvent::REDEEM_EVENTS_COUNT_BY_LEVEL[:mx], 'mx') if result.success
|
if @check_level == "smtp" && validation_eventable.validation_events.count > 1
|
||||||
|
validation_eventable.validation_events.order!(created_at: :asc)
|
||||||
destroy_old_validations(events, ValidationEvent::REDEEM_EVENTS_COUNT_BY_LEVEL[:smtp], 'smtp')
|
while validation_eventable.validation_events.count > 1
|
||||||
|
validation_eventable.validation_events.first.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_result(result)
|
def save_result(result)
|
||||||
|
|
|
@ -4,7 +4,7 @@ require 'syslog/logger'
|
||||||
require 'active_record'
|
require 'active_record'
|
||||||
|
|
||||||
namespace :verify_email do
|
namespace :verify_email do
|
||||||
# bundle exec rake verify_email:check_all -- --domain_name=shop.test --check_level=mx --spam_protect=true
|
# bundle exec rake verify_email:check_all -- --check_level=mx --spam_protect=true
|
||||||
# bundle exec rake verify_email:check_all -- -dshop.test -cmx -strue
|
# bundle exec rake verify_email:check_all -- -dshop.test -cmx -strue
|
||||||
desc 'Starts verifying email jobs with optional check level and spam protection'
|
desc 'Starts verifying email jobs with optional check level and spam protection'
|
||||||
task check_all: :environment do
|
task check_all: :environment do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue