Added domain delete rejection notification #2786

This commit is contained in:
Priit Tark 2015-07-28 17:49:35 +03:00
parent 8a92591df7
commit acb9f2ee08
6 changed files with 79 additions and 0 deletions

View file

@ -8,6 +8,7 @@ class DomainDeleteConfirmJob < Que::Job
domain.apply_pending_delete!
domain.clean_pendings!
when RegistrantVerification::REJECTED
DomainMailer.pending_delete_rejected_notification(domain).deliver_now
domain.clean_pendings!
end
destroy # it's best to destroy the job in the same transaction

View file

@ -123,4 +123,24 @@ class DomainMailer < ApplicationMailer
subject: "#{I18n.t(:domain_pending_deleted_subject,
name: @domain.name)} [#{@domain.name}]")
end
def pending_delete_rejected_notification(domain)
@domain = domain
# no delivery off control, driggered by que, no epp request
if @domain.registrant_verification_token.blank?
logger.warn "EMAIL NOT DELIVERED: registrant_verification_token is missing for #{@domain.name}"
return
end
if @domain.registrant_verification_asked_at.blank?
logger.warn "EMAIL NOT DELIVERED: registrant_verification_asked_at is missing for #{@domain.name}"
return
end
return if whitelist_blocked?(@domain.registrant.email)
mail(to: @domain.registrant.email,
subject: "#{I18n.t(:pending_delete_rejected_notification_subject,
name: @domain.name)} [#{@domain.name}]")
end
end

View file

@ -0,0 +1,15 @@
Tere,
<br><br>
Domeeni <%= @domain.name %> kustutamise taotlus on registreerija <%= @domain.registrar_name %> poolt tagasi lükatud.
<br><br>
Lugupidamisega<br>
Eesti Interneti SA
<br><br>
<hr>
<br><br>
Hi,
<br><br>
Domain <%= @domain.name %> deletion rejected.
<br><br>
Best Regards,<br>
Estonian Internet Foundation

View file

@ -0,0 +1,15 @@
Tere,
Domeeni <%= @domain.name %> kustutamise taotlus on registreerija <%= @domain.registrar_name %> poolt tagasi lükatud.
Lugupidamisega
Eesti Interneti SA
--------------------------------------
Hi,
Domain <%= @domain.name %> deletion rejected.
Best Regards,
Estonian Internet Foundation

View file

@ -784,6 +784,7 @@ en:
registrant_updated_notification_for_new_registrant_subject: 'Domeeni %{name} registreerija vahetus teostatud / Registrant change of %{name} has been finished.'
registrant_updated_notification_for_old_registrant_subject: 'Domeeni %{name} registreerija vahetus teostatud / Registrant change of %{name} has been finished.'
domain_pending_deleted_subject: "Kinnitustaotlus domeeni %{name} kustutamiseks .ee registrist / Application for approval for deletion of %{name}"
pending_delete_rejected_notification_subject: "Domeeni %{name} kustutamise taotlus tagasi lükatud / %{name) deletion declined"
whois: WHOIS
login_failed_check_id_card: 'Log in failed, check ID card'
not_valid_domain_verification_title: Domain verification not available

View file

@ -248,4 +248,31 @@ describe DomainMailer do
@mail.body.encoded.should =~ %r{registrant\/domain_delete_con} # somehowe delete_confirms not matching
end
end
describe 'email pending delete notification' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, name: 'delete-pending-rejected.ee', registrant: @registrant)
@domain.deliver_emails = true
@domain.registrant_verification_token = '123'
@domain.registrant_verification_asked_at = Time.zone.now
@mail = DomainMailer.pending_delete_rejected_notification(@domain)
end
it 'should render email subject' do
@mail.subject.should =~ /kustutamise taotlus tagasi lükatud/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send confirm email to old registrant email' do
@mail.to.should == ["test@example.com"]
end
it 'should render body' do
@mail.body.encoded.should =~ /deletion rejected/
end
end
end