From: Peter Amstutz Date: Fri, 25 Sep 2020 22:17:13 +0000 (-0400) Subject: Merge branch '16874-configure-welcome-mail' refs #16874 X-Git-Tag: 2.1.0~36 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/22e3ec0b8647ba1236d1f0e0cd55dcdb4cca7702?hp=2e8b59d84088588205d1d649f689008bae631b6f Merge branch '16874-configure-welcome-mail' refs #16874 Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- diff --git a/lib/config/config.default.yml b/lib/config/config.default.yml index 15e7c7c06c..d0338e8c86 100644 --- a/lib/config/config.default.yml +++ b/lib/config/config.default.yml @@ -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 diff --git a/lib/config/export.go b/lib/config/export.go index 6ab69d21fe..81c6767a10 100644 --- a/lib/config/export.go +++ b/lib/config/export.go @@ -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, diff --git a/lib/config/generated_config.go b/lib/config/generated_config.go index 7ed332151b..88d71eb0ac 100644 --- a/lib/config/generated_config.go +++ b/lib/config/generated_config.go @@ -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 diff --git a/sdk/go/arvados/config.go b/sdk/go/arvados/config.go index 394e30a737..00438bf340 100644 --- a/sdk/go/arvados/config.go +++ b/sdk/go/arvados/config.go @@ -219,6 +219,7 @@ type Cluster struct { UserNotifierEmailFrom string UserProfileNotificationAddress string PreferDomainForUsername string + UserSetupMailText string } Volumes map[string]Volume Workbench struct { diff --git a/services/api/app/controllers/arvados/v1/users_controller.rb b/services/api/app/controllers/arvados/v1/users_controller.rb index cd23706d08..76e8da0c72 100644 --- a/services/api/app/controllers/arvados/v1/users_controller.rb +++ b/services/api/app/controllers/arvados/v1/users_controller.rb @@ -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 diff --git a/services/api/app/views/user_notifier/account_is_setup.text.erb b/services/api/app/views/user_notifier/account_is_setup.text.erb index 50d164bfa1..352ee7754e 100644 --- a/services/api/app/views/user_notifier/account_is_setup.text.erb +++ b/services/api/app/views/user_notifier/account_is_setup.text.erb @@ -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) %> diff --git a/services/api/test/functional/arvados/v1/users_controller_test.rb b/services/api/test/functional/arvados/v1/users_controller_test.rb index ea5d5b1436..e0f7b8970d 100644 --- a/services/api/test/functional/arvados/v1/users_controller_test.rb +++ b/services/api/test/functional/arvados/v1/users_controller_test.rb @@ -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: { diff --git a/services/api/test/unit/user_notifier_test.rb b/services/api/test/unit/user_notifier_test.rb index da6c7fdb88..c288786c13 100644 --- a/services/api/test/unit/user_notifier_test.rb +++ b/services/api/test/unit/user_notifier_test.rb @@ -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