mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
added new condition for contacts which need to check
This commit is contained in:
parent
22454c4869
commit
490c44b4ba
2 changed files with 10 additions and 2 deletions
|
@ -6,7 +6,7 @@
|
||||||
# For email_validation event kind also check_level (regex/mx/smtp) is stored in the event_data
|
# For email_validation event kind also check_level (regex/mx/smtp) is stored in the event_data
|
||||||
class ValidationEvent < ApplicationRecord
|
class ValidationEvent < ApplicationRecord
|
||||||
enum event_type: ValidationEvent::EventType::TYPES, _suffix: true
|
enum event_type: ValidationEvent::EventType::TYPES, _suffix: true
|
||||||
VALIDATION_PERIOD = 1.month.freeze
|
VALIDATION_PERIOD = 1.day.freeze
|
||||||
VALID_CHECK_LEVELS = %w[regex mx smtp].freeze
|
VALID_CHECK_LEVELS = %w[regex mx smtp].freeze
|
||||||
VALID_EVENTS_COUNT_THRESHOLD = 5
|
VALID_EVENTS_COUNT_THRESHOLD = 5
|
||||||
|
|
||||||
|
|
|
@ -46,11 +46,19 @@ def logger
|
||||||
@logger ||= ActiveSupport::TaggedLogging.new(Syslog::Logger.new('registry'))
|
@logger ||= ActiveSupport::TaggedLogging.new(Syslog::Logger.new('registry'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Here I set the time after which the validation is considered obsolete
|
||||||
|
# I take all contact records that have successfully passed the verification and fall within the deadline
|
||||||
|
# I am looking for contacts that have not been verified or their verification is out of date
|
||||||
|
|
||||||
def prepare_contacts(options)
|
def prepare_contacts(options)
|
||||||
if options[:domain_name].present?
|
if options[:domain_name].present?
|
||||||
contacts_by_domain(options[:domain_name])
|
contacts_by_domain(options[:domain_name])
|
||||||
else
|
else
|
||||||
Contact.all
|
time = Time.zone.now - ValidationEvent::VALIDATION_PERIOD
|
||||||
|
validation_events_ids = ValidationEvent.where('created_at > ?', time).pluck(:validation_eventable_id)
|
||||||
|
|
||||||
|
Contact.where.not(id: validation_events_ids)
|
||||||
|
# contacts.reject(&:need_to_start_force_delete?) # temporarily commented out code
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue