diff --git a/app/controllers/notifications_settings_controller.rb b/app/controllers/notifications_settings_controller.rb index f03f09c8..6c588c32 100644 --- a/app/controllers/notifications_settings_controller.rb +++ b/app/controllers/notifications_settings_controller.rb @@ -3,8 +3,10 @@ class NotificationsSettingsController < ApplicationController before_action :load_bcc_config, only: :index before_action :load_reminder_config, only: :index + before_action :load_email_footer_config, only: :index authorize_resource :bcc_config, only: :index authorize_resource :reminder_config, only: :index + authorize_resource :email_footer_config, only: :index before_action :build_account_config, only: :create authorize_resource :account_config, only: :create @@ -36,9 +38,15 @@ class NotificationsSettingsController < ApplicationController def load_reminder_config @reminder_config = AccountConfig.find_or_initialize_by(account: current_account, key: AccountConfig::SUBMITTER_REMINDERS) + endload_email_footer_config + @email_footer_config = + AccountConfig.find_or_initialize_by(account: currnt_account, key: AccountConfig::EMAIL_FOOTER_MESSAGE_KEY) end - def email_config_params + def e + allowed = [AccountConfig::BCC_EMAILS, AccountConfig::SUBMITTER_REMINDERS, AccountConfig::EMAIL_FOOTER_MESSAGE_KEY] + + def email_config_paramsallwed params.require(:account_config).permit(:key, :value, { value: {} }, { value: [] }).tap do |attrs| attrs[:key] = nil unless attrs[:key].in?([AccountConfig::BCC_EMAILS, AccountConfig::SUBMITTER_REMINDERS]) end diff --git a/app/models/account_config.rb b/app/models/account_config.rb index fd8220a6..6c571d18 100644 --- a/app/models/account_config.rb +++ b/app/models/account_config.rb @@ -59,6 +59,7 @@ class AccountConfig < ApplicationRecord TEMPLATE_CUSTOM_FIELDS_KEY = 'template_custom_fields' POLICY_LINKS_KEY = 'policy_links' ENABLE_MCP_KEY = 'enable_mcp' + EMAIL_FOOTER_MESSAGE_KEY = 'email_footer_message' SHOW_CONSOLE_LINK_KEY = 'show_console_link' SHOW_API_LINK_KEY = 'show_api_link' SHOW_TEST_MODE_KEY = 'show_test_mode' diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb index 62b825ff..1812d775 100644 --- a/app/views/layouts/mailer.html.erb +++ b/app/views/layouts/mailer.html.erb @@ -7,6 +7,15 @@
<%= yield %> + <% footer_account = @current_account || (@submitter&.account) || (@submission&.account) %> + <% if footer_account %> + <% footer_value, _locked = footer_account.config_value(AccountConfig::EMAIL_FOOTER_MESSAGE_KEY) %> + <% if footer_value.present? %> +