diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb
index fcb8ed6ca..96a7e2350 100644
--- a/app/models/domain_mail_model.rb
+++ b/app/models/domain_mail_model.rb
@@ -15,8 +15,7 @@ class DomainMailModel
end
def pending_update_notification_for_new_registrant
- # NB! new registrant at this point
- registrant
+ registrant # new registrant at this point
subject(:pending_update_notification_for_new_registrant_subject)
domain_info
compose
@@ -30,16 +29,16 @@ class DomainMailModel
end
def registrant_updated_notification_for_old_registrant
+ registrant_pending
registrant_old
subject(:registrant_updated_notification_for_old_registrant_subject)
- registrant_name
compose
end
def pending_update_rejected_notification_for_new_registrant
registrant_pending
subject(:pending_update_rejected_notification_for_new_registrant_subject)
- @params[:deliver_emails] = true # trigger from que
+ @params[:deliver_emails] = true # triggered from que
@params[:registrar_name] = @domain.registrar.name
compose
end
@@ -92,10 +91,6 @@ class DomainMailModel
@params[:recipient] = format @domain.registrant.email
end
- def registrant_name
- @params[:registrant_name] = @domain.registrant.name
- end
-
def registrant_pending
@params[:recipient] = format @domain.pending_json['new_registrant_email']
@params[:new_registrant_name] = @domain.pending_json['new_registrant_name']
diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb
index 189b5aa1c..c95e98e7e 100644
--- a/app/models/epp/domain.rb
+++ b/app/models/epp/domain.rb
@@ -503,6 +503,10 @@ class Epp::Domain < Domain
preclean_pendings
user = ApiUser.find(pending_json['current_user_id'])
frame = Nokogiri::XML(pending_json['frame'])
+
+ self.deliver_emails = true # turn on email delivery
+ send_mail :registrant_updated_notification_for_old_registrant
+
statuses.delete(DomainStatus::PENDING_UPDATE)
yield(self) if block_given? # need to skip statuses check here
self.save
@@ -510,8 +514,7 @@ class Epp::Domain < Domain
::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user
return unless update(frame, user, false)
clean_pendings!
- self.deliver_emails = true # turn on email delivery
- send_mail :registrant_updated_notification_for_old_registrant
+
send_mail :registrant_updated_notification_for_new_registrant
true
end
diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb
index 1ad338816..f4312da44 100644
--- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb
+++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb
@@ -3,7 +3,7 @@ Tere,
Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
Uued registreerija:
-Nimi: <%= @params[:registrant_name] %>
+Nimi: <%= @params[:new_registrant_name] %>
Lugupidamisega
Eesti Interneti SA
@@ -15,7 +15,7 @@ Hi,
Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated.
New registrant:
-Name: <%= @params[:registrant_name] %>
+Name: <%= @params[:new_registrant_name] %>
Best Regards,
Estonian Internet Foundation
diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb
index beae5cfd8..f17ba0bce 100644
--- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb
+++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb
@@ -3,7 +3,7 @@ Tere,
Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
Uued registreerija:
-Nimi: <%= @params[:registrant_name] %>
+Nimi: <%= @params[:new_registrant_name] %>
Lugupidamisega
Eesti Interneti SA
@@ -15,7 +15,7 @@ Hi,
Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated.
New registrant:
-Name: <%= @params[:registrant_name] %>
+Name: <%= @params[:new_registrant_name] %>
Best Regards,
Estonian Internet Foundation