FEATURE: Add welcome message for admins. (#8293)
This commit is contained in:
parent
ee5799805c
commit
671f303b53
|
@ -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",
|
||||
|
|
|
@ -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!
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue