fix(dolist): reduce message name variability

This commit is contained in:
simon lehericey 2022-10-20 14:19:21 +02:00 committed by LeSim
parent 3e2b6cc088
commit 097082afc9
2 changed files with 10 additions and 1 deletions

View file

@ -3,6 +3,8 @@ class ApplicationMailer < ActionMailer::Base
default from: "#{APPLICATION_NAME} <#{CONTACT_EMAIL}>" default from: "#{APPLICATION_NAME} <#{CONTACT_EMAIL}>"
layout 'mailer' layout 'mailer'
before_action :add_dolist_header
# Dont retry to send a message if the server rejects the recipient address # Dont retry to send a message if the server rejects the recipient address
rescue_from Net::SMTPSyntaxError do |_error| rescue_from Net::SMTPSyntaxError do |_error|
message.perform_deliveries = false message.perform_deliveries = false
@ -28,4 +30,12 @@ class ApplicationMailer < ActionMailer::Base
Sentry.capture_exception(e, extra: { procedure_id: procedure.id }) Sentry.capture_exception(e, extra: { procedure_id: procedure.id })
nil nil
end 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 end

View file

@ -6,7 +6,6 @@ ActiveSupport.on_load(:action_mailer) do
mail.sender(ENV['DOLIST_NO_REPLY_EMAIL']) mail.sender(ENV['DOLIST_NO_REPLY_EMAIL'])
mail['X-ACCOUNT-ID'] = Rails.application.secrets.dolist[:account_id] mail['X-ACCOUNT-ID'] = Rails.application.secrets.dolist[:account_id]
mail['X-Dolist-Message-Name'] = mail.subject # for tracking in Dolist UI
mail['X-Dolist-Sending-Type'] = 'TransactionalService' # send even if the target is not active mail['X-Dolist-Sending-Type'] = 'TransactionalService' # send even if the target is not active
super(mail) super(mail)