From 89f8175850a9279036053b2a6785980a479e08d8 Mon Sep 17 00:00:00 2001 From: Ward Vandewege Date: Tue, 10 Aug 2021 11:00:02 -0400 Subject: [PATCH] 18001: add Users/UserNotifierEmailBcc configuration option, which is the e-mail address that will be bcc'd on the new user welcome e-mail. Arvados-DCO-1.1-Signed-off-by: Ward Vandewege --- lib/config/config.default.yml | 1 + lib/config/export.go | 1 + lib/config/generated_config.go | 1 + sdk/go/arvados/config.go | 1 + services/api/app/mailers/user_notifier.rb | 7 ++++++- services/api/config/arvados_config.rb | 1 + services/api/test/unit/user_notifier_test.rb | 2 ++ 7 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/config/config.default.yml b/lib/config/config.default.yml index 8640e71418..ec32613905 100644 --- a/lib/config/config.default.yml +++ b/lib/config/config.default.yml @@ -273,6 +273,7 @@ Clusters: AdminNotifierEmailFrom: arvados@example.com EmailSubjectPrefix: "[ARVADOS] " UserNotifierEmailFrom: arvados@example.com + UserNotifierEmailBcc: {} NewUserNotificationRecipients: {} NewInactiveUserNotificationRecipients: {} diff --git a/lib/config/export.go b/lib/config/export.go index 2a3d0e173a..065011cc2e 100644 --- a/lib/config/export.go +++ b/lib/config/export.go @@ -227,6 +227,7 @@ var whitelist = map[string]bool{ "Users.NewUsersAreActive": false, "Users.PreferDomainForUsername": false, "Users.UserNotifierEmailFrom": false, + "Users.UserNotifierEmailBcc": false, "Users.UserProfileNotificationAddress": false, "Users.UserSetupMailText": false, "Volumes": true, diff --git a/lib/config/generated_config.go b/lib/config/generated_config.go index 55e8ba8f36..36a21d4c35 100644 --- a/lib/config/generated_config.go +++ b/lib/config/generated_config.go @@ -279,6 +279,7 @@ Clusters: AdminNotifierEmailFrom: arvados@example.com EmailSubjectPrefix: "[ARVADOS] " UserNotifierEmailFrom: arvados@example.com + UserNotifierEmailBcc: {} NewUserNotificationRecipients: {} NewInactiveUserNotificationRecipients: {} diff --git a/sdk/go/arvados/config.go b/sdk/go/arvados/config.go index cc1de1be42..4a7c18b3e0 100644 --- a/sdk/go/arvados/config.go +++ b/sdk/go/arvados/config.go @@ -234,6 +234,7 @@ type Cluster struct { NewUserNotificationRecipients StringSet NewUsersAreActive bool UserNotifierEmailFrom string + UserNotifierEmailBcc StringSet UserProfileNotificationAddress string PreferDomainForUsername string UserSetupMailText string diff --git a/services/api/app/mailers/user_notifier.rb b/services/api/app/mailers/user_notifier.rb index ad887d035a..03000a3730 100644 --- a/services/api/app/mailers/user_notifier.rb +++ b/services/api/app/mailers/user_notifier.rb @@ -9,7 +9,12 @@ class UserNotifier < ActionMailer::Base def account_is_setup(user) @user = user - mail(to: user.email, subject: 'Welcome to Arvados - account enabled') + if not Rails.configuration.Users.UserNotifierEmailBcc.empty? then + @bcc = Rails.configuration.Users.UserNotifierEmailBcc.keys + mail(to: user.email, subject: 'Welcome to Arvados - account enabled', bcc: @bcc) + else + mail(to: user.email, subject: 'Welcome to Arvados - account enabled') + end end end diff --git a/services/api/config/arvados_config.rb b/services/api/config/arvados_config.rb index 1b3c96a8ad..defe262831 100644 --- a/services/api/config/arvados_config.rb +++ b/services/api/config/arvados_config.rb @@ -96,6 +96,7 @@ arvcfg.declare_config "Users.UserProfileNotificationAddress", String, :user_prof arvcfg.declare_config "Users.AdminNotifierEmailFrom", String, :admin_notifier_email_from arvcfg.declare_config "Users.EmailSubjectPrefix", String, :email_subject_prefix arvcfg.declare_config "Users.UserNotifierEmailFrom", String, :user_notifier_email_from +arvcfg.declare_config "Users.UserNotifierEmailBcc", Hash, ->(cfg, k, v) { arrayToHash cfg, "Users.UserNotifierEmailBcc", v } arvcfg.declare_config "Users.NewUserNotificationRecipients", Hash, :new_user_notification_recipients, ->(cfg, k, v) { arrayToHash cfg, "Users.NewUserNotificationRecipients", v } arvcfg.declare_config "Users.NewInactiveUserNotificationRecipients", Hash, :new_inactive_user_notification_recipients, method(:arrayToHash) arvcfg.declare_config "Login.LoginCluster", String diff --git a/services/api/test/unit/user_notifier_test.rb b/services/api/test/unit/user_notifier_test.rb index c288786c13..e58c273a6d 100644 --- a/services/api/test/unit/user_notifier_test.rb +++ b/services/api/test/unit/user_notifier_test.rb @@ -10,6 +10,7 @@ class UserNotifierTest < ActionMailer::TestCase test "account is setup" do user = users :active + Rails.configuration.Users.UserNotifierEmailBcc = ConfigLoader.to_OrderedOptions({"bcc-notify@example.com"=>{},"bcc-notify2@example.com"=>{}}) Rails.configuration.Users.UserSetupMailText = %{ <% if not @user.full_name.empty? -%> <%= @user.full_name %>, @@ -33,6 +34,7 @@ The Arvados team. # Test the body of the sent email contains what we expect it to assert_equal Rails.configuration.Users.UserNotifierEmailFrom, email.from.first + assert_equal Rails.configuration.Users.UserNotifierEmailBcc.stringify_keys.keys, email.bcc assert_equal user.email, email.to.first assert_equal 'Welcome to Arvados - account enabled', email.subject assert (email.body.to_s.include? 'Your Arvados shell account has been set up'), -- 2.30.2