18001: add Users/UserNotifierEmailBcc configuration option, which is the
authorWard Vandewege <ward@curii.com>
Tue, 10 Aug 2021 15:00:02 +0000 (11:00 -0400)
committerWard Vandewege <ward@curii.com>
Wed, 11 Aug 2021 14:18:02 +0000 (10:18 -0400)
       e-mail address that will be bcc'd on the new user welcome e-mail.

Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward@curii.com>

lib/config/config.default.yml
lib/config/export.go
lib/config/generated_config.go
sdk/go/arvados/config.go
services/api/app/mailers/user_notifier.rb
services/api/config/arvados_config.rb
services/api/test/unit/user_notifier_test.rb

index 8640e71418fa88c51a7a8c3436949d9371bafee9..ec32613905f8ad9b40bde6820199413f5d30fe0d 100644 (file)
@@ -273,6 +273,7 @@ Clusters:
       AdminNotifierEmailFrom: arvados@example.com
       EmailSubjectPrefix: "[ARVADOS] "
       UserNotifierEmailFrom: arvados@example.com
+      UserNotifierEmailBcc: {}
       NewUserNotificationRecipients: {}
       NewInactiveUserNotificationRecipients: {}
 
index 2a3d0e173a6d23d36474a55627f6cf73b758df4e..065011cc2e8d31d2fb133f6546a32a8f506861b2 100644 (file)
@@ -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,
index 55e8ba8f36da791007b8ad9ccf755b79733d4698..36a21d4c357165628aa321ef8d97b67c1ea894bd 100644 (file)
@@ -279,6 +279,7 @@ Clusters:
       AdminNotifierEmailFrom: arvados@example.com
       EmailSubjectPrefix: "[ARVADOS] "
       UserNotifierEmailFrom: arvados@example.com
+      UserNotifierEmailBcc: {}
       NewUserNotificationRecipients: {}
       NewInactiveUserNotificationRecipients: {}
 
index cc1de1be4295201f207da20eca3c436b84161ca0..4a7c18b3e06324ab0f37a2a8db54270aedcdc2c9 100644 (file)
@@ -234,6 +234,7 @@ type Cluster struct {
                NewUserNotificationRecipients         StringSet
                NewUsersAreActive                     bool
                UserNotifierEmailFrom                 string
+               UserNotifierEmailBcc                  StringSet
                UserProfileNotificationAddress        string
                PreferDomainForUsername               string
                UserSetupMailText                     string
index ad887d035a339ff0039884237d394e820a077023..03000a37308ad287a2b5f75538dd25ab4054a3be 100644 (file)
@@ -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
index 1b3c96a8adfe55dd58085512969a59844d9a64d6..defe26283108d628d7428e6b9fb6eaf772f5f840 100644 (file)
@@ -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
index c288786c1323246c589af91aa53fc3d0aa37c557..e58c273a6d85adebff1dc1d3d113fa01f6b3a893 100644 (file)
@@ -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'),