diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb
index 2310eaad4..9fd21f22e 100644
--- a/app/jobs/domain_update_confirm_job.rb
+++ b/app/jobs/domain_update_confirm_job.rb
@@ -8,6 +8,7 @@ class DomainUpdateConfirmJob < Que::Job
domain.apply_pending_update!
domain.clean_pendings!
when RegistrantVerification::REJECTED
+ DomainMailer.pending_update_rejected_new_registrant_notification(domain).deliver_now
domain.clean_pendings!
end
destroy # it's best to destroy the job in the same transaction
diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb
index 822d4a22f..00b5cfb8d 100644
--- a/app/mailers/domain_mailer.rb
+++ b/app/mailers/domain_mailer.rb
@@ -57,6 +57,19 @@ class DomainMailer < ApplicationMailer
name: @domain.name)} [#{@domain.name}]")
end
+ def pending_update_rejected_new_registrant_notification(domain)
+ @domain = domain
+ # no delivery off control, driggered by que, no epp request
+
+ @new_registrant_email = @domain.pending_json[:new_registrant_email]
+ @new_registrant_name = @domain.pending_json[:new_registrant_name]
+
+ return if whitelist_blocked?(@new_registrant_email)
+ mail(to: @new_registrant_email,
+ subject: "#{I18n.t(:pending_update_rejected_new_registrant_notification_subject,
+ name: @domain.name)} [#{@domain.name}]")
+ end
+
def pending_deleted(domain)
@domain = domain
return if delivery_off?(@domain)
diff --git a/app/models/domain.rb b/app/models/domain.rb
index d77587d40..98d1e5697 100644
--- a/app/models/domain.rb
+++ b/app/models/domain.rb
@@ -359,6 +359,9 @@ class Domain < ActiveRecord::Base
token = registrant_verification_token
asked_at = registrant_verification_asked_at
changes_cache = changes
+ new_registrant_id = registrant.id
+ new_registrant_email = registrant.email
+ new_registrant_name = registrant.name
DomainMailer.pending_update_old_registrant_request(self).deliver_now
DomainMailer.pending_update_new_registrant_notification(self).deliver_now
@@ -370,6 +373,9 @@ class Domain < ActiveRecord::Base
self.registrant_verification_asked_at = asked_at
self.statuses = [DomainStatus::PENDING_UPDATE]
pending_json[:domain] = changes_cache
+ pending_json[:new_registrant_id] = new_registrant_id
+ pending_json[:new_registrant_email] = new_registrant_email
+ pending_json[:new_registrant_name] = new_registrant_name
end
# rubocop: disable Metrics/CyclomaticComplexity
diff --git a/app/views/mailers/domain_mailer/pending_update_rejected_new_registrant_notification.html.erb b/app/views/mailers/domain_mailer/pending_update_rejected_new_registrant_notification.html.erb
new file mode 100644
index 000000000..94672f176
--- /dev/null
+++ b/app/views/mailers/domain_mailer/pending_update_rejected_new_registrant_notification.html.erb
@@ -0,0 +1,19 @@
+Tere,
+
+Domeeni <%= @domain.name %> registreerija <%= @new_registrant_name %> on domeeni registreerija vahetamise taotluse tagasi lükanud.
+
+Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad
+
+Lugupidamisega,
+Eesti Interneti SA
+
+