mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 22:46:22 +02:00
Create check force delete rake task
This commit is contained in:
parent
c246bbaa6d
commit
e159821a86
5 changed files with 93 additions and 47 deletions
|
@ -12,14 +12,9 @@ module EmailVerifable
|
|||
end
|
||||
|
||||
def need_to_start_force_delete?
|
||||
flag = false
|
||||
ValidationEvent::INVALID_EVENTS_COUNT_BY_LEVEL.each do |level, count|
|
||||
if validation_events.count >= count && validate_email_data(level: level, count: count)
|
||||
flag = true
|
||||
end
|
||||
validation_events.count >= count && validate_email_data(level: level, count: count)
|
||||
end
|
||||
|
||||
flag
|
||||
end
|
||||
|
||||
def need_to_lift_force_delete?
|
||||
|
|
|
@ -35,8 +35,6 @@ class ValidationEvent < ApplicationRecord
|
|||
scope :smtp, -> { where('event_data @> ?', { 'check_level': 'smtp' }.to_json) }
|
||||
scope :by_object, ->(object) { where(validation_eventable: object) }
|
||||
|
||||
after_create :check_for_force_delete
|
||||
|
||||
def self.validated_ids_by(klass)
|
||||
recent.successful.where('validation_eventable_type = ?', klass)
|
||||
.pluck(:validation_eventable_id)
|
||||
|
@ -57,39 +55,4 @@ class ValidationEvent < ApplicationRecord
|
|||
def object
|
||||
validation_eventable
|
||||
end
|
||||
|
||||
def check_for_force_delete
|
||||
ValidationEventCheckForceDeleteJob.perform_later(id, object.id)
|
||||
end
|
||||
|
||||
def start_force_delete
|
||||
Domains::ForceDeleteEmail::Base.run(email: email)
|
||||
end
|
||||
|
||||
def refresh_status_notes
|
||||
domain_list.each do |domain|
|
||||
next unless domain.status_notes[DomainStatus::FORCE_DELETE]
|
||||
|
||||
domain.status_notes[DomainStatus::FORCE_DELETE].slice!(object.email_history)
|
||||
domain.status_notes[DomainStatus::FORCE_DELETE].lstrip!
|
||||
domain.save(validate: false)
|
||||
|
||||
notify_registrar(domain) unless domain.status_notes[DomainStatus::FORCE_DELETE].empty?
|
||||
end
|
||||
end
|
||||
|
||||
def domain_list
|
||||
domain_contacts = Contact.where(email: email).map(&:domain_contacts).flatten
|
||||
registrant_ids = Registrant.where(email: email).pluck(:id)
|
||||
|
||||
(domain_contacts.map(&:domain).flatten + Domain.where(registrant_id: registrant_ids)).uniq
|
||||
end
|
||||
|
||||
def notify_registrar(domain)
|
||||
domain.registrar.notifications.create!(text: I18n.t('force_delete_auto_email',
|
||||
domain_name: domain.name,
|
||||
outzone_date: domain.outzone_date,
|
||||
purge_date: domain.purge_date,
|
||||
email: domain.status_notes[DomainStatus::FORCE_DELETE]))
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue