From 097082afc947fb020b0a5061546410bdbf342425 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Thu, 20 Oct 2022 14:19:21 +0200 Subject: [PATCH] fix(dolist): reduce message name variability --- app/mailers/application_mailer.rb | 10 ++++++++++ config/initializers/dolist.rb | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index dd5ed4084..a09385116 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -3,6 +3,8 @@ class ApplicationMailer < ActionMailer::Base default from: "#{APPLICATION_NAME} <#{CONTACT_EMAIL}>" layout 'mailer' + before_action :add_dolist_header + # Don’t retry to send a message if the server rejects the recipient address rescue_from Net::SMTPSyntaxError do |_error| message.perform_deliveries = false @@ -28,4 +30,12 @@ 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 diff --git a/config/initializers/dolist.rb b/config/initializers/dolist.rb index fe245c93d..af4ae6169 100644 --- a/config/initializers/dolist.rb +++ b/config/initializers/dolist.rb @@ -6,7 +6,6 @@ ActiveSupport.on_load(:action_mailer) do mail.sender(ENV['DOLIST_NO_REPLY_EMAIL']) 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 super(mail)