From 7fd6f6a55d5a76910f59f9e1429ecccdb008f893 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Tue, 28 Jul 2015 11:47:48 +0300 Subject: [PATCH] Added domain pending update new registrant notification #2804 --- app/mailers/domain_mailer.rb | 23 +++++++++ ...pdate_new_registrant_notification.html.erb | 49 +++++++++++++++++++ ...pdate_new_registrant_notification.text.erb | 49 +++++++++++++++++++ config/locales/en.yml | 1 + spec/mailers/domain_mailer_spec.rb | 31 +++++++++++- 5 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 app/views/domain_mailer/pending_update_new_registrant_notification.html.erb create mode 100644 app/views/domain_mailer/pending_update_new_registrant_notification.text.erb diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index 936a4559c..f7de5171a 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -23,6 +23,29 @@ class DomainMailer < ApplicationMailer subject: "#{I18n.t(:domain_registrant_pending_updated_subject, name: @domain.name)} [#{@domain.name}]") end + def pending_update_new_registrant_notification(domain) + @domain = domain + return if delivery_off?(@domain) + + 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 + + @new_registrant = @domain.registrant # NB! new registrant at this point + @old_registrant = Registrant.find(@domain.registrant_id_was) + + return if whitelist_blocked?(@new_registrant.email) + mail(to: @new_registrant.email, + subject: "#{I18n.t(:domain_pending_update_new_registrant_notification_subject, + name: @domain.name)} [#{@domain.name}]") + end + def registrant_updated(domain) @domain = domain return if delivery_off?(@domain) diff --git a/app/views/domain_mailer/pending_update_new_registrant_notification.html.erb b/app/views/domain_mailer/pending_update_new_registrant_notification.html.erb new file mode 100644 index 000000000..27bec4401 --- /dev/null +++ b/app/views/domain_mailer/pending_update_new_registrant_notification.html.erb @@ -0,0 +1,49 @@ +Tere, +

+Registripidaja <%= @domain.registrar_name %> vahendusel on algatatud <%= @domain.name %> domeeni omanikuvahetuse protseduur. +

+Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @domain.registrar_name %> +

+Uued registreerija andmed:
+Nimi: <%= @domain.registrant_name %>
+<% if @domain.registrant.priv? %> + Isikukood: <%= @domain.registrant_ident %>
+<% else %> + Äriregistrikood: <%= @domain.registrant_ident %>
+<% end %> +Tänav: <%= @domain.registrant_street %>
+Linn: <%= @domain.registrant_city %>
+Riik: <%= @domain.registrant_country %> +

+Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiaks lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @old_registrant.name %> omanikuvahetuse tähtaegselt kinnitab. +

+Juhul kui <%= @old_registrant.name %> lükkab omanikuvahtuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse.
+

+Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ise ei kinnita või tagasi lükka. +

+Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad +

+Lugupidamisega
+Eesti Interneti SA +

+
+

+Hi, +

+Registrant change process for the domain <%= @domain.name %> has been started. +

+New registrant:
+Name: <%= @domain.registrant_name %>
+<% if @domain.registrant.priv? %> +Personal code: <%= @domain.registrant_ident %>
+<% else %> +Business Registry code: <%= @domain.registrant_ident %>
+<% end %> +Street: <%= @domain.registrant_street %>
+City: <%= @domain.registrant_city %>
+Country: <%= @domain.registrant_country %>
+

+Please contact to your registrar <%= @domain.registrar_name %> if you have any questions. +

+Best Regards,
+Estonian Internet Foundation diff --git a/app/views/domain_mailer/pending_update_new_registrant_notification.text.erb b/app/views/domain_mailer/pending_update_new_registrant_notification.text.erb new file mode 100644 index 000000000..e4a401977 --- /dev/null +++ b/app/views/domain_mailer/pending_update_new_registrant_notification.text.erb @@ -0,0 +1,49 @@ +Tere, + +Registripidaja <%= @domain.registrar_name %> vahendusel on algatatud <%= @domain.name %> domeeni omanikuvahetuse protseduur. + +Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @domain.registrar_name %> + +Uued registreerija andmed: +Nimi: <%= @domain.registrant_name %> +<% if @domain.registrant.priv? %> +Isikukood: <%= @domain.registrant_ident %> +<% else %> +Äriregistrikood: <%= @domain.registrant_ident %> +<% end %> +Tänav: <%= @domain.registrant_street %> +Linn: <%= @domain.registrant_city %> +Riik: <%= @domain.registrant_country %> + +Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiaks lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @old_registrant.name %> omanikuvahetuse tähtaegselt kinnitab. + +Juhul kui <%= @old_registrant.name %> lükkab omanikuvahtuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse. + +Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ise ei kinnita või tagasi lükka. + +Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad + +Lugupidamisega +Eesti Interneti SA + +-------------------------------------- + +Hi, + +Registrant change process for the domain <%= @domain.name %> has been started. + +New registrant: +Name: <%= @domain.registrant_name %> +<% if @domain.registrant.priv? %> +Personal code: <%= @domain.registrant_ident %> +<% else %> +Business Registry code: <%= @domain.registrant_ident %> +<% end %> +Street: <%= @domain.registrant_street %> +City: <%= @domain.registrant_city %> +Country: <%= @domain.registrant_country %> + +Please contact to your registrar <%= @domain.registrar_name %> if you have any questions. + +Best Regards, +Estonian Internet Foundation diff --git a/config/locales/en.yml b/config/locales/en.yml index fc124e6a4..a25260496 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -778,6 +778,7 @@ en: contact_email_update_subject: 'Teie domeenide kontakt epostiaadress on muutunud / Contact e-mail addresses of your domains have changed' object_status_prohibits_operation: 'Object status prohibits operation' domain_registrant_pending_updated_subject: "Kinnitustaotlus domeeni %{name} registreerija vahetuseks / Application for approval for registrant chache of %{name}" + domain_pending_update_new_registrant_notification_subject: "Domeeni %{name} registreerija vahetus protseduur on algatatud / %{name} registrant change" domain_pending_deleted_subject: "Kinnitustaotlus domeeni %{name} kustutamiseks .ee registrist / Application for approval for deletion of %{name}" whois: WHOIS login_failed_check_id_card: 'Log in failed, check ID card' diff --git a/spec/mailers/domain_mailer_spec.rb b/spec/mailers/domain_mailer_spec.rb index ada60a741..a0701c1bd 100644 --- a/spec/mailers/domain_mailer_spec.rb +++ b/spec/mailers/domain_mailer_spec.rb @@ -25,7 +25,7 @@ describe DomainMailer do end end - describe 'email changed notification' do + describe 'registrant change request for old registrant' do before :all do @registrant = Fabricate(:registrant, email: 'test@example.com') @new_registrant = Fabricate(:registrant, email: 'test@example.org') @@ -58,6 +58,35 @@ describe DomainMailer do end end + describe 'registrant change notification for new registrant' do + before :all do + @registrant = Fabricate(:registrant, email: 'old@example.com') + @new_registrant = Fabricate(:registrant, email: 'new@example.org') + @domain = Fabricate(:domain, registrant: @registrant) + @domain.deliver_emails = true + @domain.registrant_verification_token = '123' + @domain.registrant_verification_asked_at = Time.zone.now + @domain.registrant = @new_registrant + @mail = DomainMailer.pending_update_new_registrant_notification(@domain) + end + + it 'should render email subject' do + @mail.subject.should =~ /protseduur on algatatud/ + end + + it 'should have sender email' do + @mail.from.should == ["noreply@internet.ee"] + end + + it 'should send confirm email to new registrant email' do + @mail.to.should == ["new@example.org"] + end + + it 'should render body' do + @mail.body.encoded.should =~ /vahendusel on algatatud/ + end + end + describe 'domain pending delete notification when delivery turned off' do before :all do @registrant = Fabricate(:registrant, email: 'test@example.com')