Merge pull request #7945 from betagouv/improve_do_list_header

fix(dolist): réduit le nombre de  'Message-Name' possible chez dolist
This commit is contained in:
LeSim 2022-10-20 15:41:18 +02:00 committed by GitHub
commit 0dcd755fd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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}>"
layout 'mailer'
before_action :add_dolist_header
# Dont 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

View file

@ -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)