refactor(mailer): set dolist header in DeviseUserMailer

This commit is contained in:
Colin Darie 2023-01-10 15:36:58 +01:00
parent 5ae5de0d9c
commit d911bc02c0
3 changed files with 11 additions and 11 deletions

View file

@ -1,5 +1,5 @@
class ApplicationMailer < ActionMailer::Base
include MailerErrorConcern
include MailerMonitoringConcern
helper :application # gives access to all helpers defined within `application_helper`.
default from: "#{APPLICATION_NAME} <#{CONTACT_EMAIL}>"
@ -20,12 +20,4 @@ class ApplicationMailer < ActionMailer::Base
Sentry.capture_exception(e, extra: { procedure_id: procedure.id })
nil
end
# mandatory for dolist
# used for tracking in Dolist UI
# the delivery_method is yet unknown (:balancer)
# so we add the dolist header for everyone
def add_dolist_header
headers['X-Dolist-Message-Name'] = action_name
end
end

View file

@ -1,4 +1,4 @@
module MailerErrorConcern
module MailerMonitoringConcern
extend ActiveSupport::Concern
included do
@ -17,6 +17,14 @@ module MailerErrorConcern
rescue_from StandardError, with: :log_delivery_error
# mandatory for dolist
# used for tracking in Dolist UI
# the delivery_method is yet unknown (:balancer)
# so we add the dolist header for everyone
def add_dolist_header
headers['X-Dolist-Message-Name'] = action_name
end
protected
def log_delivery_error(exception)

View file

@ -3,7 +3,7 @@ class DeviseUserMailer < Devise::Mailer
helper :application # gives access to all helpers defined within `application_helper`.
helper MailerHelper
include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url`
include MailerErrorConcern
include MailerMonitoringConcern
layout 'mailers/layout'
def template_paths