A platform for community discussion. Free, open, simple.
FEATURE: Add welcome message for admins. (#8293)
Vinoth Kannan671f303b5355
diff --git a/app/controllers/admin/email_templates_controller.rb b/app/controllers/admin/email_templates_controller.rbindex 9a3f8ea78e7..d1b06c830ea 100644--- a/app/controllers/admin/email_templates_controller.rb+++ b/app/controllers/admin/email_templates_controller.rb@@ -43,6 +43,7 @@ class Admin::EmailTemplatesController < Admin::AdminController"system_messages.user_automatically_silenced","system_messages.welcome_invite","system_messages.welcome_user",+ "system_messages.welcome_staff","test_mailer","user_notifications.account_created","user_notifications.admin_login",diff --git a/app/models/concerns/roleable.rb b/app/models/concerns/roleable.rbindex 07062692400..b1f15d4996d 100644--- a/app/models/concerns/roleable.rb+++ b/app/models/concerns/roleable.rb@@ -20,7 +20,7 @@ module Roleabledef grant_moderation!set_permission('moderator', true)- enqueue_welcome_moderator_message+ enqueue_staff_welcome_message(:moderator)enddef revoke_moderation!@@ -29,6 +29,7 @@ module Roleabledef grant_admin!set_permission('admin', true)+ enqueue_staff_welcome_message(:admin)enddef revoke_admin!diff --git a/app/models/user.rb b/app/models/user.rbindex aa5ac937a02..adaf9ee9bbd 100644--- a/app/models/user.rb+++ b/app/models/user.rb@@ -416,9 +416,17 @@ class User < ActiveRecord::BaseJobs.enqueue(:send_system_message, user_id: id, message_type: "welcome_tl1_user")end- def enqueue_welcome_moderator_message- return unless moderator- Jobs.enqueue(:send_system_message, user_id: id, message_type: 'welcome_moderator')+ def enqueue_staff_welcome_message(role)+ return unless staff?++ Jobs.enqueue(+ :send_system_message,+ user_id: id,+ message_type: 'welcome_staff',+ message_options: {+ role: role+ }+ )enddef change_username(new_username, actor = nil)diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex bdebcbbdd54..b1619c47d4e 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -2677,13 +2677,13 @@ en:We’re really glad you’re spending time with us and we’d love to know more about you. Take a moment to [fill out your profile](%{base_url}/my/preferences/profile), or feel free to [start a new topic](%{base_url}/categories).- welcome_moderator:- title: "Welcome Moderator"- subject_template: "Congratulations, you’re now a moderator!"+ welcome_staff:+ title: "Welcome Staff"+ subject_template: "Congratulations, you’re now a %{role}!"text_body_template: |- You’ve been granted moderator status by a fellow staff member.+ You’ve been granted %{role} status by a fellow staff member.- As a moderator, you now have access to the <a href='%{base_url}/admin' target='_blank'>admin interface</a>.+ As a %{role}, you now have access to the <a href='%{base_url}/admin' target='_blank'>admin interface</a>.With great power comes great responsibility. If you’re new to moderating, please refer to the [Moderation Guide](https://meta.discourse.org/t/discourse-moderation-guide/63116).welcome_invite:diff --git a/spec/components/admin_confirmation_spec.rb b/spec/components/admin_confirmation_spec.rbindex 1c09b8f2362..749c566090d 100644--- a/spec/components/admin_confirmation_spec.rb+++ b/spec/components/admin_confirmation_spec.rb@@ -33,6 +33,7 @@ describe AdminConfirmation doexpect(ac.performed_by).to eq(admin)expect(ac.target_user).to eq(user)expect(ac.token).to eq(@token)+ Jobs.expects(:enqueue).with(:send_system_message, user_id: user.id, message_type: 'welcome_staff', message_options: { role: :admin })ac.email_confirmed!user.reloaddiff --git a/spec/requests/admin/users_controller_spec.rb b/spec/requests/admin/users_controller_spec.rbindex 9a3d280b48c..e6bf9831d20 100644--- a/spec/requests/admin/users_controller_spec.rb+++ b/spec/requests/admin/users_controller_spec.rb@@ -426,6 +426,7 @@ RSpec.describe Admin::UsersController doendit 'updates the moderator flag' do+ Jobs.expects(:enqueue).with(:send_system_message, user_id: another_user.id, message_type: 'welcome_staff', message_options: { role: :moderator })put "/admin/users/#{another_user.id}/grant_moderation.json"expect(response.status).to eq(200)another_user.reload