mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
added possebility to recheck invalid contacts and also remove old records
This commit is contained in:
parent
1ec79afb11
commit
761ce9bd6d
3 changed files with 44 additions and 10 deletions
|
@ -16,6 +16,7 @@ module Actions
|
|||
maybe_update_ident if ident.present?
|
||||
maybe_attach_legal_doc
|
||||
maybe_change_email
|
||||
maybe_filtering_old_failed_records
|
||||
commit
|
||||
end
|
||||
|
||||
|
@ -35,6 +36,15 @@ module Actions
|
|||
true
|
||||
end
|
||||
|
||||
def maybe_filtering_old_failed_records
|
||||
if contact.validation_events.count > 1
|
||||
contact.validation_events.order!(created_at: :asc)
|
||||
while contact.validation_events.count >= 1
|
||||
contact.validation_events.first.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def maybe_remove_address
|
||||
return if Contact.address_processing?
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ module Actions
|
|||
def call
|
||||
result = check_email(email)
|
||||
save_result(result)
|
||||
filtering_old_failed_records(result)
|
||||
result.success ? log_success : log_failure(result)
|
||||
result.success
|
||||
end
|
||||
|
@ -25,6 +26,29 @@ module Actions
|
|||
Rails.env.test? && check_level == 'smtp' ? :mx : check_level.to_sym
|
||||
end
|
||||
|
||||
def filtering_old_failed_records(result)
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
if @check_level == "smtp" && 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
|
||||
end
|
||||
|
||||
def save_result(result)
|
||||
validation_eventable.validation_events.create(validation_event_attrs(result))
|
||||
rescue ActiveRecord::RecordNotSaved
|
||||
|
|
|
@ -71,9 +71,9 @@ def filter_check_level(contact)
|
|||
if data.failed?
|
||||
return false if data.event_data['check_level'] == 'regex'
|
||||
|
||||
return false if data.event_data['check_level'] == 'smtp'
|
||||
|
||||
return false if check_mx_contact_validation(contact)
|
||||
# return false if data.event_data['check_level'] == 'smtp'
|
||||
#
|
||||
# return false if check_mx_contact_validation(contact)
|
||||
|
||||
return true
|
||||
end
|
||||
|
@ -92,13 +92,13 @@ def failed_contacts
|
|||
failed_contacts.uniq
|
||||
end
|
||||
|
||||
def check_mx_contact_validation(contact)
|
||||
data = contact.validation_events.mx.order(created_at: :asc).last(ValidationEvent::MX_CHECK)
|
||||
|
||||
return false if data.size < ValidationEvent::MX_CHECK
|
||||
|
||||
data.all? { |d| d.failed? }
|
||||
end
|
||||
# def check_mx_contact_validation(contact)
|
||||
# data = contact.validation_events.mx.order(created_at: :asc).last(ValidationEvent::MX_CHECK)
|
||||
#
|
||||
# return false if data.size < ValidationEvent::MX_CHECK
|
||||
#
|
||||
# data.all? { |d| d.failed? }
|
||||
# end
|
||||
|
||||
def contacts_by_domain(domain_name)
|
||||
domain = ::Domain.find_by(name: domain_name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue