mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 21:46:24 +02:00
added validation command
This commit is contained in:
parent
1ce5ebd629
commit
20cbdbfa75
2 changed files with 31 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
class VerifyEmailsJob < ApplicationJob
|
class VerifyEmailsJob < ApplicationJob
|
||||||
discard_on StandardError
|
discard_on StandardError
|
||||||
|
|
||||||
def perform(email:, check_level: 'mx')
|
def perform(email:, check_level: 'mx', single_check: false)
|
||||||
contact = Contact.find_by(email: email)
|
contact = Contact.find_by(email: email)
|
||||||
|
|
||||||
return logger.info "Contact #{email} not found!" if contact.nil?
|
return logger.info "Contact #{email} not found!" if contact.nil?
|
||||||
|
@ -11,7 +11,7 @@ class VerifyEmailsJob < ApplicationJob
|
||||||
validate_check_level(check_level)
|
validate_check_level(check_level)
|
||||||
|
|
||||||
logger.info "Trying to verify contact email #{email} with check_level #{check_level}"
|
logger.info "Trying to verify contact email #{email} with check_level #{check_level}"
|
||||||
contact.verify_email(check_level: check_level)
|
contact.verify_email(check_level: check_level, single_email: single_check)
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
handle_error(e)
|
handle_error(e)
|
||||||
end
|
end
|
||||||
|
|
29
lib/tasks/verify_domain.rake
Normal file
29
lib/tasks/verify_domain.rake
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
require 'optparse'
|
||||||
|
require 'rake_option_parser_boilerplate'
|
||||||
|
require 'syslog/logger'
|
||||||
|
require 'active_record'
|
||||||
|
|
||||||
|
SPAM_PROTECT_TIMEOUT = 30.seconds
|
||||||
|
|
||||||
|
task verify_domain: :environment do
|
||||||
|
options = {
|
||||||
|
domain_name: nil,
|
||||||
|
check_level: 'mx',
|
||||||
|
spam_protect: false,
|
||||||
|
}
|
||||||
|
banner = 'Usage: rake verify_domain -- [options]'
|
||||||
|
options = RakeOptionParserBoilerplate.process_args(options: options,
|
||||||
|
banner: banner,
|
||||||
|
hash: opts_hash)
|
||||||
|
|
||||||
|
|
||||||
|
domain = Domain.find_by(name: options[:domain_name])
|
||||||
|
check_level = options[:check_level]
|
||||||
|
|
||||||
|
domain.domain_contacts.each do |dc|
|
||||||
|
dc.contact.verify_email(check_level: check_level, single_email: true)
|
||||||
|
|
||||||
|
Rails.logger.info "Validated contact with code #{dc.contact.code} and email #{dc.contact.email} of #{domain.name} domain"
|
||||||
|
Rails.logger.info "Result - #{dc.contact.validation_events.last.success}"
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue