clean(SMTP.balancing): remove some env vars

This commit is contained in:
Martin 2022-05-02 17:30:37 +02:00 committed by mfo
parent 529da2d80f
commit a0df24b631
6 changed files with 15 additions and 29 deletions

View file

@ -25,7 +25,7 @@ as defined by the routes in the `admin/` namespace
<%= link_to "Delayed Jobs", manager_delayed_job_path, class: "navigation__link" %> <%= link_to "Delayed Jobs", manager_delayed_job_path, class: "navigation__link" %>
<%= link_to "Features", manager_flipper_path, class: "navigation__link" %> <%= link_to "Features", manager_flipper_path, class: "navigation__link" %>
<% if ENV["SENDINBLUE_ENABLED"] == "enabled" && ENV["SAML_IDP_ENABLED"] == "enabled" %> <% if Rails.application.secrets.sendinblue[:enabled] && ENV["SAML_IDP_ENABLED"] == "enabled" %>
<%= link_to "Sendinblue", ENV.fetch("SENDINBLUE_LOGIN_URL"), class: "navigation__link", target: '_blank' %> <%= link_to "Sendinblue", ENV.fetch("SENDINBLUE_LOGIN_URL"), class: "navigation__link", target: '_blank' %>
<% end %> <% end %>
</nav> </nav>

View file

@ -84,19 +84,12 @@ MATOMO_HOST="matomo.example.org"
MAILJET_API_KEY="" MAILJET_API_KEY=""
MAILJET_SECRET_KEY="" MAILJET_SECRET_KEY=""
# Alternate SMTP Provider: SendInBlue # Alternate SMTP Provider: SendInBlue/DoList
SENDINBLUE_ENABLED="disabled"
SENDINBLUE_CLIENT_KEY="" SENDINBLUE_CLIENT_KEY=""
SENDINBLUE_SMTP_KEY="" SENDINBLUE_SMTP_KEY=""
SENDINBLUE_USER_NAME="" SENDINBLUE_USER_NAME=""
# SENDINBLUE_LOGIN_URL="https://app.sendinblue.com/account/saml/login/truc" # SENDINBLUE_LOGIN_URL="https://app.sendinblue.com/account/saml/login/truc"
# Ratio of emails sent using SendInBlue
# When enabled, N % of emails will be sent using SendInBlue
# (and the others using the default SMTP provider)
SENDINBLUE_BALANCING="disabled"
SENDINBLUE_BALANCING_VALUE="50"
# Alternate SMTP Provider: Mailtrap (mail catcher for staging environments) # Alternate SMTP Provider: Mailtrap (mail catcher for staging environments)
# When enabled, all emails will be sent using this provider # When enabled, all emails will be sent using this provider
MAILTRAP_ENABLED="disabled" MAILTRAP_ENABLED="disabled"

View file

@ -119,3 +119,12 @@ MATOMO_IFRAME_URL="https://matomo.example.org/index.php?module=CoreAdminHome&act
# DOLIST_ACCOUNT_ID="" # DOLIST_ACCOUNT_ID=""
# DOLIST_NO_REPLY_EMAIL="" # DOLIST_NO_REPLY_EMAIL=""
# DOLIST_API_KEY="" # DOLIST_API_KEY=""
# Ratio of emails sent using SendInBlue
# When present, N % of emails will be sent using SendInBlue
# (and the others using the default SMTP provider)
SENDINBLUE_BALANCING_VALUE="50"
# Ratio of emails sent using DoList
# When present, N % of emails will be sent using DoList
# (and the others using the default SMTP provider)
DOLIST_BALANCING_VALUE="50"

View file

@ -81,24 +81,8 @@ Rails.application.configure do
elsif ENV['MAILCATCHER_ENABLED'] == 'enabled' elsif ENV['MAILCATCHER_ENABLED'] == 'enabled'
config.action_mailer.delivery_method = :mailcatcher config.action_mailer.delivery_method = :mailcatcher
else else
sendinblue_weigth = ENV.fetch('SENDINBLUE_BALANCING_VALUE') { 0 }.to_i
sendinblue_weigth = case [ENV['SENDINBLUE_ENABLED'] == 'enabled', ENV['SENDINBLUE_BALANCING'] == 'enabled'] dolist_weigth = ENV.fetch('DOLIST_BALANCING_VALUE') { 0 }.to_i
in [false, _]
0
in [true, false]
100
else
ENV.fetch('SENDINBLUE_BALANCING_VALUE').to_i
end
dolist_weigth = case [ENV['DOLIST_ENABLED'] == 'enabled', ENV['DOLIST_BALANCING'] == 'enabled']
in [false, _]
0
in [true, false]
100
else
ENV.fetch('DOLIST_BALANCING_VALUE').to_i
end
ActionMailer::Base.add_delivery_method :balancer, BalancerDeliveryMethod ActionMailer::Base.add_delivery_method :balancer, BalancerDeliveryMethod
config.action_mailer.balancer_settings = { config.action_mailer.balancer_settings = {

View file

@ -1,4 +1,4 @@
if ENV.fetch('SENDINBLUE_ENABLED') == 'enabled' if ENV.key?('SENDINBLUE_BALANCING_VALUE')
require 'sib-api-v3-sdk' require 'sib-api-v3-sdk'
ActiveSupport.on_load(:action_mailer) do ActiveSupport.on_load(:action_mailer) do

View file

@ -53,7 +53,7 @@ defaults: &defaults
client_secret: <%= ENV['HELPSCOUT_CLIENT_SECRET'] %> client_secret: <%= ENV['HELPSCOUT_CLIENT_SECRET'] %>
webhook_secret: <%= ENV['HELPSCOUT_WEBHOOK_SECRET'] %> webhook_secret: <%= ENV['HELPSCOUT_WEBHOOK_SECRET'] %>
sendinblue: sendinblue:
enabled: <%= ENV['SENDINBLUE_ENABLED'] == 'enabled' %> enabled: <%= ENV.key?('SENDINBLUE_BALANCING_VALUE') %>
username: <%= ENV['SENDINBLUE_USER_NAME'] %> username: <%= ENV['SENDINBLUE_USER_NAME'] %>
client_key: <%= ENV['SENDINBLUE_CLIENT_KEY'] %> client_key: <%= ENV['SENDINBLUE_CLIENT_KEY'] %>
smtp_key: <%= ENV['SENDINBLUE_SMTP_KEY'] %> smtp_key: <%= ENV['SENDINBLUE_SMTP_KEY'] %>