mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 10:49:39 +02:00
Story#117124725 - generate emails of apply_pending_update! only when everything is ok
This commit is contained in:
parent
1d5a79f406
commit
a091c62264
8 changed files with 108 additions and 103 deletions
|
@ -20,28 +20,7 @@ class DomainMailModel
|
|||
domain_info
|
||||
compose
|
||||
end
|
||||
|
||||
def registrant_updated_notification_for_new_registrant
|
||||
registrant
|
||||
subject(:registrant_updated_notification_for_new_registrant_subject)
|
||||
domain_info
|
||||
compose
|
||||
end
|
||||
|
||||
def registrant_updated_notification_for_old_registrant
|
||||
registrant_pending
|
||||
registrant_old
|
||||
subject(:registrant_updated_notification_for_old_registrant_subject)
|
||||
new_registrant = Registrant.find @domain.pending_json['new_registrant_id']
|
||||
@params[:registrant_name] = new_registrant.name
|
||||
@params[:registrant_ident] = new_registrant.ident
|
||||
@params[:registrant_priv] = new_registrant.priv?
|
||||
@params[:registrant_email] = new_registrant.email
|
||||
@params[:registrant_street] = new_registrant.street
|
||||
@params[:registrant_city] = new_registrant.city
|
||||
@params[:registrant_country] = new_registrant.country.name
|
||||
compose
|
||||
end
|
||||
|
||||
def pending_update_rejected_notification_for_new_registrant
|
||||
registrant_pending
|
||||
|
|
|
@ -525,19 +525,21 @@ class Epp::Domain < Domain
|
|||
preclean_pendings
|
||||
user = ApiUser.find(pending_json['current_user_id'])
|
||||
frame = Nokogiri::XML(pending_json['frame'])
|
||||
old_registrant_id = registrant_id
|
||||
|
||||
self.deliver_emails = true # turn on email delivery
|
||||
self.statuses.delete(DomainStatus::PENDING_UPDATE)
|
||||
::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user
|
||||
|
||||
send_mail :registrant_updated_notification_for_old_registrant
|
||||
return unless update(frame, user, false)
|
||||
clean_pendings!
|
||||
|
||||
send_mail :registrant_updated_notification_for_new_registrant
|
||||
WhoisRecord.find_by(domain_id: id).save # need to reload model
|
||||
|
||||
save! # for notification if everything fails
|
||||
|
||||
WhoisRecord.find_by(domain_id: id).save # need to reload model
|
||||
DomainMailer.registrant_updated_notification_for_old_registrant(id, old_registrant_id, registrant_id, should_deliver)
|
||||
DomainMailer.registrant_updated_notification_for_new_registrant(id, old_registrant_id, registrant_id, should_deliver)
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue