Merge branch '16874-configure-welcome-mail' refs #16874
authorPeter Amstutz <peter.amstutz@curii.com>
Fri, 25 Sep 2020 22:17:13 +0000 (18:17 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Fri, 25 Sep 2020 22:17:13 +0000 (18:17 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

lib/config/config.default.yml
lib/config/export.go
lib/config/generated_config.go
sdk/go/arvados/config.go
services/api/app/controllers/arvados/v1/users_controller.rb
services/api/app/views/user_notifier/account_is_setup.text.erb
services/api/test/functional/arvados/v1/users_controller_test.rb
services/api/test/unit/user_notifier_test.rb

index 15e7c7c06ce723114cafc86d8e4c6ec0c2b99dff..d0338e8c86636480dc9640c9683039f2a94b1603 100644 (file)
@@ -287,6 +287,20 @@ Clusters:
       # address is used.
       PreferDomainForUsername: ""
 
+      UserSetupMailText: |
+        <% if not @user.full_name.empty? -%>
+        <%= @user.full_name %>,
+        <% else -%>
+        Hi there,
+        <% end -%>
+
+        Your Arvados account has been set up.  You can log in at
+
+        <%= Rails.configuration.Services.Workbench1.ExternalURL %>
+
+        Thanks,
+        Your Arvados administrator.
+
     AuditLogs:
       # Time to keep audit logs, in seconds. (An audit log is a row added
       # to the "logs" table in the PostgreSQL database each time an
index 6ab69d21fe13eaec3dff84a3ef74e8febc88ff1b..81c6767a10996fd684305fcc328b27310f4e1234 100644 (file)
@@ -214,6 +214,7 @@ var whitelist = map[string]bool{
        "Users.PreferDomainForUsername":                false,
        "Users.UserNotifierEmailFrom":                  false,
        "Users.UserProfileNotificationAddress":         false,
+       "Users.UserSetupMailText":                      false,
        "Volumes":                                      true,
        "Volumes.*":                                    true,
        "Volumes.*.*":                                  false,
index 7ed332151b8bbacaa81fa7352e8251058296b8c8..88d71eb0ac83b76c38cbeedc0df8456eba70bf52 100644 (file)
@@ -293,6 +293,20 @@ Clusters:
       # address is used.
       PreferDomainForUsername: ""
 
+      UserSetupMailText: |
+        <% if not @user.full_name.empty? -%>
+        <%= @user.full_name %>,
+        <% else -%>
+        Hi there,
+        <% end -%>
+
+        Your Arvados account has been set up.  You can log in at
+
+        <%= Rails.configuration.Services.Workbench1.ExternalURL %>
+
+        Thanks,
+        Your Arvados administrator.
+
     AuditLogs:
       # Time to keep audit logs, in seconds. (An audit log is a row added
       # to the "logs" table in the PostgreSQL database each time an
index 394e30a737e2aff13128df90d96decfc12428863..00438bf340a36851ff48262d6df998ce9407f112 100644 (file)
@@ -219,6 +219,7 @@ type Cluster struct {
                UserNotifierEmailFrom                 string
                UserProfileNotificationAddress        string
                PreferDomainForUsername               string
+               UserSetupMailText                     string
        }
        Volumes   map[string]Volume
        Workbench struct {
index cd23706d08140f2176fccb063ed5b4070202536a..76e8da0c72b306c7fc33612f5c345d866624c1fa 100644 (file)
@@ -135,7 +135,7 @@ class Arvados::V1::UsersController < ApplicationController
                               vm_uuid: params[:vm_uuid])
 
     # setup succeeded. send email to user
-    if params[:send_notification_email]
+    if params[:send_notification_email] && !Rails.configuration.Users.UserSetupMailText.empty?
       begin
         UserNotifier.account_is_setup(@object).deliver_now
       rescue => e
index 50d164bfa1e8493cef0b9d733062f6cfb4c8fbb6..352ee7754e1e6855c1b2ffc946dad5c24d0962fe 100644 (file)
@@ -2,17 +2,4 @@
 
 SPDX-License-Identifier: AGPL-3.0 %>
 
-<% if not @user.full_name.empty? -%>
-<%= @user.full_name %>,
-<% else -%>
-Hi there,
-<% end -%>
-
-Your Arvados shell account has been set up. Please visit the virtual machines page <% if Rails.configuration.Services.Workbench1.ExternalURL %>at
-
-  <%= Rails.configuration.Services.Workbench1.ExternalURL %><%= "/" if !Rails.configuration.Services.Workbench1.ExternalURL.to_s.end_with?("/") %>users/<%= @user.uuid%>/virtual_machines <% else %><% end %>
-
-for connection instructions.
-
-Thanks,
-The Arvados team.
+<%= ERB.new(Rails.configuration.Users.UserSetupMailText, 0, "-").result(binding) %>
index ea5d5b1436bd256506cc1c23061dfd81eb8a763f..e0f7b8970dfd34f2a161a75336ef4a3bc964acd1 100644 (file)
@@ -609,6 +609,23 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
   test "setup user with send notification param true and verify email" do
     authorize_with :admin
 
+    Rails.configuration.Users.UserSetupMailText = %{
+<% if not @user.full_name.empty? -%>
+<%= @user.full_name %>,
+<% else -%>
+Hi there,
+<% end -%>
+
+Your Arvados shell account has been set up. Please visit the virtual machines page <% if Rails.configuration.Services.Workbench1.ExternalURL %>at
+
+<%= Rails.configuration.Services.Workbench1.ExternalURL %><%= "/" if !Rails.configuration.Services.Workbench1.ExternalURL.to_s.end_with?("/") %>users/<%= @user.uuid%>/virtual_machines <% else %><% end %>
+
+for connection instructions.
+
+Thanks,
+The Arvados team.
+}
+
     post :setup, params: {
       send_notification_email: 'true',
       user: {
index da6c7fdb88bc825c9918bb0dd92aa7c53a7b7aea..c288786c1323246c589af91aa53fc3d0aa37c557 100644 (file)
@@ -9,6 +9,24 @@ class UserNotifierTest < ActionMailer::TestCase
   # Send the email, then test that it got queued
   test "account is setup" do
     user = users :active
+
+    Rails.configuration.Users.UserSetupMailText = %{
+<% if not @user.full_name.empty? -%>
+<%= @user.full_name %>,
+<% else -%>
+Hi there,
+<% end -%>
+
+Your Arvados shell account has been set up. Please visit the virtual machines page <% if Rails.configuration.Services.Workbench1.ExternalURL %>at
+
+<%= Rails.configuration.Services.Workbench1.ExternalURL %><%= "/" if !Rails.configuration.Services.Workbench1.ExternalURL.to_s.end_with?("/") %>users/<%= @user.uuid%>/virtual_machines <% else %><% end %>
+
+for connection instructions.
+
+Thanks,
+The Arvados team.
+}
+
     email = UserNotifier.account_is_setup user
 
     assert_not_nil email