diff --git a/app/lib/dolist/api.rb b/app/lib/dolist/api.rb index 87e401a0a..cc0d44bae 100644 --- a/app/lib/dolist/api.rb +++ b/app/lib/dolist/api.rb @@ -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). diff --git a/config/env.example.optional b/config/env.example.optional index ffd7ecf02..371df1072 100644 --- a/config/env.example.optional +++ b/config/env.example.optional @@ -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="" diff --git a/config/secrets.yml b/config/secrets.yml index efb986716..61cd28651 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -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: