mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 16:32:04 +02:00
Refactor contact mailer
- Send single email with new email in `to` and old email in `bcc` fields - Remove `Que::Mailer` (#895) - Add preview - DRY templates - Add tests - Extract translations - Remove useless specs
This commit is contained in:
parent
6fa1ce9128
commit
5674071838
12 changed files with 122 additions and 125 deletions
|
@ -45,7 +45,6 @@ class Contact < ActiveRecord::Base
|
|||
|
||||
before_validation :to_upcase_country_code
|
||||
before_validation :strip_email
|
||||
before_update :manage_emails
|
||||
|
||||
composed_of :identifier,
|
||||
class_name: 'Contact::Ident',
|
||||
|
@ -54,18 +53,6 @@ class Contact < ActiveRecord::Base
|
|||
country_code: country_code) },
|
||||
mapping: [%w[ident code], %w[ident_type type], %w[ident_country_code country_code]]
|
||||
|
||||
def manage_emails
|
||||
return nil unless email_changed?
|
||||
return nil unless deliver_emails == true
|
||||
emails = []
|
||||
emails << [email, email_was]
|
||||
emails = emails.flatten.uniq
|
||||
emails.each do |e|
|
||||
ContactMailer.email_updated(email_was, e, id, deliver_emails).deliver
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
after_save :update_related_whois_records
|
||||
|
||||
ORG = 'org'
|
||||
|
@ -77,8 +64,6 @@ class Contact < ActiveRecord::Base
|
|||
# From old registry software ("Fred"). No new contact can be created with this status
|
||||
PASSPORT = 'passport'
|
||||
|
||||
attr_accessor :deliver_emails
|
||||
|
||||
#
|
||||
# STATUSES
|
||||
#
|
||||
|
|
|
@ -145,8 +145,6 @@ class Epp::Contact < Contact
|
|||
self.legal_document_id = doc.id
|
||||
end
|
||||
|
||||
self.deliver_emails = true # turn on email delivery for epp
|
||||
|
||||
ident_frame = frame.css('ident').first
|
||||
|
||||
# https://github.com/internetee/registry/issues/576
|
||||
|
@ -175,7 +173,17 @@ class Epp::Contact < Contact
|
|||
self.upid = current_user.registrar.id if current_user.registrar
|
||||
self.up_date = Time.zone.now
|
||||
|
||||
super(at)
|
||||
self.attributes = at
|
||||
|
||||
email_changed = email_changed?
|
||||
old_email = email_was
|
||||
updated = save
|
||||
|
||||
if updated && email_changed
|
||||
ContactMailer.email_changed(contact: self, old_email: old_email).deliver_now
|
||||
end
|
||||
|
||||
updated
|
||||
end
|
||||
|
||||
def statuses_attrs(frame, action)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue