Merge pull request #10357 from demarches-simplifiees/fix_dolist_gouv_sender

Tech: pour le prestataire de mail dolist, choisit le bon sender_id en fonction du domaine utilisé (migration gouv.fr)
This commit is contained in:
Colin Darie 2024-04-22 09:43:34 +00:00 committed by GitHub
commit c52ff5cdeb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 4 deletions

View file

@ -190,9 +190,11 @@ module Dolist
format(base, account_id: account_id)
end
def sender_id
Rails.cache.fetch("dolist_api_sender_id", expires_in: 1.hour) do
senders.dig("ItemList", 0, "Sender", "ID")
def sender_id(domain)
if domain == "demarches.gouv.fr"
Rails.application.secrets.dolist[:gouv_sender_id]
else
Rails.application.secrets.dolist[:default_sender_id]
end
end
@ -267,7 +269,7 @@ module Dolist
"Message": {
"Name": mail['X-Dolist-Message-Name'].value,
"Subject": mail.subject,
"SenderID": sender_id,
"SenderID": sender_id(mail.from_address.domain),
"ForceHttp": false, # ForceHttp : force le tracking http non sécurisé (True/False).
"Format": "html",
"DisableOpenTracking": true, # DisableOpenTracking : désactivation du tracking d'ouverture (True/False).

View file

@ -137,6 +137,7 @@ MATOMO_IFRAME_URL="https://matomo.example.org/index.php?module=CoreAdminHome&act
# DOLIST_ACCOUNT_ID=""
# DOLIST_NO_REPLY_EMAIL=""
# DOLIST_API_KEY=""
# DOLIST_DEFAULT_SENDER_ID=""
# SMTP Provider: SIB (Brevo)
# SENDINBLUE_SMTP_ADDRESS=""

View file

@ -32,6 +32,8 @@ defaults: &defaults
password: <%= ENV['DOLIST_PASSWORD'] %>
account_id: <%= ENV['DOLIST_ACCOUNT_ID'] %>
api_key: <%= ENV['DOLIST_API_KEY'] %>
default_sender_id: <%= ENV['DOLIST_DEFAULT_SENDER_ID'] || 1 %>
gouv_sender_id: <%= ENV['DOLIST_GOUV_SENDER_ID'] || 1 %>
api_entreprise:
key: <%= ENV['API_ENTREPRISE_KEY'] %>
mailtrap: