FEATURE: Add welcome message for admins. (#8293)

This commit is contained in:
Vinoth Kannan 2019-11-05 18:15:55 +05:30 committed by GitHub
parent ee5799805c
commit 671f303b53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 9 deletions

View File

@ -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",

View File

@ -20,7 +20,7 @@ module Roleable
def grant_moderation!
set_permission('moderator', true)
enqueue_welcome_moderator_message
enqueue_staff_welcome_message(:moderator)
end
def revoke_moderation!
@ -29,6 +29,7 @@ module Roleable
def grant_admin!
set_permission('admin', true)
enqueue_staff_welcome_message(:admin)
end
def revoke_admin!

View File

@ -416,9 +416,17 @@ class User < ActiveRecord::Base
Jobs.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
}
)
end
def change_username(new_username, actor = nil)

View File

@ -2677,13 +2677,13 @@ en:
Were really glad youre spending time with us and wed 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, youre now a moderator!"
welcome_staff:
title: "Welcome Staff"
subject_template: "Congratulations, youre now a %{role}!"
text_body_template: |
Youve been granted moderator status by a fellow staff member.
Youve 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 youre new to moderating, please refer to the [Moderation Guide](https://meta.discourse.org/t/discourse-moderation-guide/63116).
welcome_invite:

View File

@ -33,6 +33,7 @@ describe AdminConfirmation do
expect(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.reload

View File

@ -426,6 +426,7 @@ RSpec.describe Admin::UsersController do
end
it '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