Skip to content

Commit

Permalink
Merge pull request #2432 from internetee/missing-force-delete-template
Browse files Browse the repository at this point in the history
Missing force delete template
  • Loading branch information
vohmar authored Sep 8, 2022
2 parents 7a624de + fbf947f commit 1b7f879
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/interactions/domains/force_delete/notify_registrar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def notify_without_email
outzone_date: domain.outzone_date,
purge_date: domain.purge_date)

return if domain.registrar.notifications.last.text.include? template
return if domain.registrar&.notifications&.last&.text&.include? template

domain.registrar.notifications.create!(text: template)
end
Expand All @@ -23,7 +23,7 @@ def notify_with_email
purge_date: domain.purge_date,
email: email)

return if domain.registrar.notifications.last.text.include? template
return if domain.registrar&.notifications&.last&.text&.include? template

domain.registrar.notifications.create!(text: template)
end
Expand Down
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<p>Lugupeetud domeeni <%= @domain.name %> registreerija/halduskontakt</p>

<p>Eesti Interneti Sihtasutusele (EIS) on saanud teatavaks, et domeeni <%= @domain.name %> kontaktandmed on puudulikud - eposti aadress <%= @domain.contact_emails_verification_failed %>.</p>

<p>Et see olukord on vastuolus .ee <a href='https://www.internet.ee/domains/ee-domain-regulation'>domeenireeglitega</a> algatas EIS <%= @delete_period_length %> päeva pikkuse kustutusmenetluse. Menetluse käigus on domeen <%= @expire_warning_period %> esimest päeva internetis kättesaadav.</p>

<p>Andmete parandamiseks pöörduge palun oma registripidaja <%= @registrar.name %> poole või isiklike ja oma ettevõtte andmete puhul <a href="https://registrant.internet.ee/">registreerija portaali</a>.</p>

<p>Kui kontaktandmed ei ole <%= @delete_period_length %> päeva jooksul parandatud, läheb domeen <%= @domain.name %> <%= @domain.force_delete_date %> domeenioksjonile <a href="https://auction.internet.ee">.ee oksjonikeskkonda</a>. Juhul kui domeenile <%= @domain.name %> ei tehta oksjonil 24h möödudes pakkumist, domeen vabaneb ja on registreerimiseks vabalt kättesaadav kõigile huvilistele. Muude võimalike oksjoni tulemuste kohta loe <a href="https://www.internet.ee/domeenid/domeenide-oksjonikeskkonna-kasutajatingimused#3-oksjonikeskkonna-enampakkumisel-osalemise-tingimused">siit</a>.</p>

<p>Lisaküsimuste korral võtke palun ühendust oma registripidajaga:</p>
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
<%= render 'mailers/shared/signatures/signature.et.html' %>

<hr>

<p>Dear registrant/administrative contact of .ee domain,</p>

<p>Estonian Internet Foundation has learned that contact data of the domain <%= @domain.name %> s invalid - email(s) <%= @domain.contact_emails_verification_failed %>.</p>

<p>Since this is a violation of <a href='https://www.internet.ee/domains/ee-domain-regulation'>Estonian domain regulations</a>, <%= @delete_period_length %>-day deletion process has started for the <%= @domain.name %> domain. For the first <%= @expire_warning_period %> days the domain will remain available on the Internet during the deletion process.</p>

<p>Please, contact your registrar <%= @registrar.name %> with updated contact data, or in case of your personal or business data use <a href="https://registrant.internet.ee/">.ee portal for registrants</a></p>

<p>If the data is not fixed within <%= @delete_period_length %> days, the domain <%= @domain.name %> will go to domain auction on <%= @domain.force_delete_date %> in the <a href="https://auction.internet.ee">.ee auction environment</a>. If no offer is made for the domain <%= @domain.name %> at auction within 24 hours, the domain will be released and made freely available for registration to anyone interested on a first-come, first-served basis. Read more about other potential auction results <a href="https://www.internet.ee/domains/auction-environment-user-agreement#3-terms-and-conditions-for-participation-in-the-auction-of-the-auction-environment">here</a>.</p>

<p>Should you have additional questions, please contact your registrar:</p>
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
<%= render 'mailers/shared/signatures/signature.en.html' %>
<hr>

<p>Уважаемый регистрант/административный контакт домена .ee</p>

<p>Целевому учреждению Eesti Internet (EIS) стало известно, что контактные данные домена <%= @registrant.reg_no %> неверны - электронная почта <%= @domain.contact_emails_verification_failed %>.</p>

<p>Так как это является нарушением <a href='https://www.internet.ee/domains/ee-domain-regulation'>Правил домена .ee</a>, <%= @delete_period_length %>-дневный процесс удаления начат для доменного имени <%= @domain.name %>. В течение первых <%= @expire_warning_period %> дней домен будет доступен в интернете.</p>

<p>Для уточнения контактных данных, пожалуйста, свяжитесь с регистратором <%= @registrar.name %>, либо воспользуйтесь <a href="https://registrant.internet.ee/">порталом для регистрантов</a></p>

<p>Если контактные данные не будут исправлены в течение <%= @delete_period_length %> дней, домен <%= @domain.name %> отправится <%= @domain.force_delete_date %> на доменный аукцион в <a href="https://auction.internet.ee">аукционной среде.ee</a>. Если в течение 24 часов в отношении домена <%= @domain.name %> е поступит предложений, домен освободится и станет доступным для всех желающих по принципу «кто раньше». О других возможных результатах аукциона читайте <a href="https://www.internet.ee/domains/auction-environment-user-agreement#3-terms-and-conditions-for-participation-in-the-auction-of-the-auction-environment">здесь</a>.</p>

<p>В случае возникновения дополнительных вопросов свяжитесь, пожалуйста, со своим регистратором:
<%= render 'mailers/shared/registrar/registrar.ru.html', registrar: @registrar %></p>

<%= render 'mailers/shared/signatures/signature.ru.html' %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<p>Lugupeetud domeeni <%= @domain.name %> registreerija/halduskontakt</p>

<p>Eesti Interneti Sihtasutusele (EIS) on saanud teatavaks, et domeeni <%= @domain.name %> kontaktandmed on puudulikud - eposti aadress <%= @domain.contact_emails_verification_failed %></p>

<p>Et see olukord on vastuolus .ee <a href='https://www.internet.ee/domains/ee-domain-regulation'>domeenireeglitega</a> algatas EIS <%= @delete_period_length %> päeva pikkuse kustutusmenetluse. Menetluse käigus on domeen <%= @expire_warning_period %> esimest päeva internetis kättesaadav.</p>

<p>Andmete parandamiseks pöörduge palun oma registripidaja <%= @registrar.name %> poole või isiklike ja oma ettevõtte andmete puhul <a href="https://registrant.internet.ee/">registreerija portaali</a>.</p>

<p>Kui kontaktandmed ei ole <%= @delete_period_length %> päeva jooksul parandatud, läheb domeen <%= @domain.name %> <%= @domain.force_delete_date %> domeenioksjonile <a href="https://auction.internet.ee">.ee oksjonikeskkonda</a>. Juhul kui domeenile <%= @domain.name %> ei tehta oksjonil 24h möödudes pakkumist, domeen vabaneb ja on registreerimiseks vabalt kättesaadav kõigile huvilistele. Muude võimalike oksjoni tulemuste kohta loe <a href="https://www.internet.ee/domeenid/domeenide-oksjonikeskkonna-kasutajatingimused#3-oksjonikeskkonna-enampakkumisel-osalemise-tingimused">siit</a>.</p>

<p>Lisaküsimuste korral võtke palun ühendust oma registripidajaga:</p>
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
<%= render 'mailers/shared/signatures/signature.et.html' %>

<hr>

<p>Dear registrant/administrative contact of .ee domain,</p>

<p>Estonian Internet Foundation has learned that contact data of the domain <%= @domain.name %> s invalid - email(s) <%= @domain.contact_emails_verification_failed %>.</p>

<p>Since this is a violation of <a href='https://www.internet.ee/domains/ee-domain-regulation'>Estonian domain regulations</a>, <%= @delete_period_length %>-day deletion process has started for the <%= @domain.name %> domain. For the first <%= @expire_warning_period %> days the domain will remain available on the Internet during the deletion process.</p>

<p>Please, contact your registrar <%= @registrar.name %> with updated contact data, or in case of your personal or business data use <a href="https://registrant.internet.ee/">.ee portal for registrants</a></p>

<p>If the data is not fixed within <%= @delete_period_length %> days, the domain <%= @domain.name %> will go to domain auction on <%= @domain.force_delete_date %> in the <a href="https://auction.internet.ee">.ee auction environment</a>. If no offer is made for the domain <%= @domain.name %> at auction within 24 hours, the domain will be released and made freely available for registration to anyone interested on a first-come, first-served basis. Read more about other potential auction results <a href="https://www.internet.ee/domains/auction-environment-user-agreement#3-terms-and-conditions-for-participation-in-the-auction-of-the-auction-environment">here</a>.</p>

<p>Should you have additional questions, please contact your registrar:</p>
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
<%= render 'mailers/shared/signatures/signature.en.html' %>
<hr>

<p>Уважаемый регистрант/административный контакт домена .ee</p>

<p>Целевому учреждению Eesti Internet (EIS) стало известно, что контактные данные домена <%= @registrant.reg_no %> неверны - электронная почта <%= @domain.contact_emails_verification_failed %>.</p>

<p>Так как это является нарушением <a href='https://www.internet.ee/domains/ee-domain-regulation'>Правил домена .ee</a>, <%= @delete_period_length %>-дневный процесс удаления начат для доменного имени <%= @domain.name %>. В течение первых <%= @expire_warning_period %> дней домен будет доступен в интернете.</p>

<p>Для уточнения контактных данных, пожалуйста, свяжитесь с регистратором <%= @registrar.name %>, либо воспользуйтесь <a href="https://registrant.internet.ee/">порталом для регистрантов</a></p>

<p>Если контактные данные не будут исправлены в течение <%= @delete_period_length %> дней, домен <%= @domain.name %> отправится <%= @domain.force_delete_date %> на доменный аукцион в <a href="https://auction.internet.ee">аукционной среде.ee</a>. Если в течение 24 часов в отношении домена <%= @domain.name %> е поступит предложений, домен освободится и станет доступным для всех желающих по принципу «кто раньше». О других возможных результатах аукциона читайте <a href="https://www.internet.ee/domains/auction-environment-user-agreement#3-terms-and-conditions-for-participation-in-the-auction-of-the-auction-environment">здесь</a>.</p>

<p>В случае возникновения дополнительных вопросов свяжитесь, пожалуйста, со своим регистратором:
<%= render 'mailers/shared/registrar/registrar.ru.html', registrar: @registrar %></p>

<%= render 'mailers/shared/signatures/signature.ru.html' %>
2 changes: 2 additions & 0 deletions lib/tasks/check_force_delete.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ task check_force_delete: :environment do

invalid_contact_ids = validations.select do |validation|
contact = validation.validation_eventable
next if contact.nil?

contact.need_to_start_force_delete? || contact.need_to_lift_force_delete?
end.pluck(:validation_eventable_id)

Expand Down
17 changes: 17 additions & 0 deletions test/mailers/domain_delete_mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,21 @@ def test_delivers_domain_force_delete_email
' / Domain shop.test is in deletion process' \
' / Домен shop.test в процессе удаления', email.subject
end

def test_forced_invalid_email
@domain.update(template_name: 'invalid_email')
@domain.reload

email = DomainDeleteMailer.forced(domain: @domain,
registrar: @domain.registrar,
registrant: @domain.registrant,
template_name: @domain.template_name).deliver_now

assert_emails 1
assert_equal ['[email protected]'], email.from
assert @domain.force_delete_contact_emails.sort == email.to.sort
assert_equal 'Domeen shop.test on kustutusmenetluses' \
' / Domain shop.test is in deletion process' \
' / Домен shop.test в процессе удаления', email.subject
end
end

0 comments on commit 1b7f879

Please sign in to comment.