mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 20:55:44 +02:00
implement prototype of invalid emails data parser
This commit is contained in:
parent
cac386a099
commit
940fb2b4ed
2 changed files with 38 additions and 16 deletions
|
@ -2,26 +2,10 @@ class ApplicationMailer < ActionMailer::Base
|
|||
append_view_path Rails.root.join('app', 'views', 'mailers')
|
||||
layout 'mailer'
|
||||
|
||||
before_action :verification_before_send
|
||||
|
||||
def registrant_confirm_url(domain:, method:)
|
||||
token = domain.registrant_verification_token
|
||||
base_url = ENV['registrant_portal_verifications_base_url']
|
||||
|
||||
"#{base_url}/confirmation/#{domain.name_puny}/#{method}/#{token}"
|
||||
end
|
||||
|
||||
def verification_before_send
|
||||
p '==================================================================='
|
||||
p '==================================================================='
|
||||
p '==================================================================='
|
||||
p '==================================================================='
|
||||
p '==================================================================='
|
||||
p mail
|
||||
p '==================================================================='
|
||||
p '==================================================================='
|
||||
p '==================================================================='
|
||||
p '==================================================================='
|
||||
p '==================================================================='
|
||||
end
|
||||
end
|
||||
|
|
38
lib/tasks/collect_invalid_validation_contacts.rake
Normal file
38
lib/tasks/collect_invalid_validation_contacts.rake
Normal file
|
@ -0,0 +1,38 @@
|
|||
namespace :collect_invalid_contacts do
|
||||
desc 'Starts collect invalid validation contacts'
|
||||
task all_domains: :environment do
|
||||
Contact.all.each do |contact|
|
||||
result = Truemail.validate(contact.email, with: :mx)
|
||||
unless result.result.success
|
||||
collect_data_for_csv(contact, result.result)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def find_related_domains(contact)
|
||||
Domain.where(id: contact.id)
|
||||
end
|
||||
|
||||
def collect_data_for_csv(contact, result)
|
||||
domains = find_related_domains(contact)
|
||||
|
||||
headers = %w[
|
||||
contact
|
||||
domain
|
||||
error
|
||||
]
|
||||
|
||||
CSV.open('invalid_email.csv', 'w') do |csv|
|
||||
csv << headers
|
||||
|
||||
domains.each do |domain|
|
||||
attrs = []
|
||||
attrs.push(domain)
|
||||
attrs.push(contact.email)
|
||||
attrs.push(result.errors)
|
||||
|
||||
csv << attrs
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue