Skip to content

Commit

Permalink
returned back missing peace of code from #2349 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
olegphenomenon committed Sep 2, 2022
1 parent 693d1c5 commit 6c66ba7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/models/concerns/domain/force_delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ def notification_template(explicit: nil)
reason = explicit&.downcase
return reason if %w[invalid_email invalid_phone].include?(reason)

registrant.org? ? 'legal_person' : 'private_person'
if contact_emails_verification_failed.present?
'invalid_email'
elsif registrant.org?
'legal_person'
else
'private_person'
end
end

def force_delete_scheduled?
Expand Down
4 changes: 4 additions & 0 deletions app/models/concerns/email_verifable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ module EmailVerifable
scope :recently_not_validated, -> { where.not(id: ValidationEvent.validated_ids_by(name)) }
end

def email_verification_failed?
need_to_start_force_delete?
end

def validate_email_data(level:, count:)
validation_events.order(created_at: :desc).limit(count).all? do |event|
event.check_level == level.to_s && event.failed?
Expand Down
5 changes: 5 additions & 0 deletions app/models/contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class Contact < ApplicationRecord
alias_attribute :kind, :ident_type
alias_attribute :copy_from_id, :original_id # Old attribute name; for PaperTrail

scope :email_verification_failed, lambda {
joins('LEFT JOIN email_address_verifications emv ON contacts.email = emv.email')
.where('success = false and verified_at IS NOT NULL')
}

scope :with_different_company_name, (lambda do |company|
where("ident = ? AND ident_country_code = 'EE' AND name != ?",
company.registration_number,
Expand Down
4 changes: 4 additions & 0 deletions app/models/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,10 @@ def domain_name
DNS::DomainName.new(name)
end

def contact_emails_verification_failed
contacts.select(&:email_verification_failed?)&.map(&:email)&.uniq
end

def as_csv_row
[
name,
Expand Down
4 changes: 4 additions & 0 deletions app/presenters/domain_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def force_delete_toggle_btn
end
end

def contact_emails_verification_failed
domain.contact_emails_verification_failed.join(', ')
end

def remove_registry_lock_btn
return unless domain.locked_by_registrant?

Expand Down

0 comments on commit 6c66ba7

Please sign in to comment.