mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 07:31:02 +08:00
FEATURE: Add welcome message for admins. (#8293)
This commit is contained in:
@ -43,6 +43,7 @@ class Admin::EmailTemplatesController < Admin::AdminController
|
|||||||
"system_messages.user_automatically_silenced",
|
"system_messages.user_automatically_silenced",
|
||||||
"system_messages.welcome_invite",
|
"system_messages.welcome_invite",
|
||||||
"system_messages.welcome_user",
|
"system_messages.welcome_user",
|
||||||
|
"system_messages.welcome_staff",
|
||||||
"test_mailer",
|
"test_mailer",
|
||||||
"user_notifications.account_created",
|
"user_notifications.account_created",
|
||||||
"user_notifications.admin_login",
|
"user_notifications.admin_login",
|
||||||
|
@ -20,7 +20,7 @@ module Roleable
|
|||||||
|
|
||||||
def grant_moderation!
|
def grant_moderation!
|
||||||
set_permission('moderator', true)
|
set_permission('moderator', true)
|
||||||
enqueue_welcome_moderator_message
|
enqueue_staff_welcome_message(:moderator)
|
||||||
end
|
end
|
||||||
|
|
||||||
def revoke_moderation!
|
def revoke_moderation!
|
||||||
@ -29,6 +29,7 @@ module Roleable
|
|||||||
|
|
||||||
def grant_admin!
|
def grant_admin!
|
||||||
set_permission('admin', true)
|
set_permission('admin', true)
|
||||||
|
enqueue_staff_welcome_message(:admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
def revoke_admin!
|
def revoke_admin!
|
||||||
|
@ -416,9 +416,17 @@ class User < ActiveRecord::Base
|
|||||||
Jobs.enqueue(:send_system_message, user_id: id, message_type: "welcome_tl1_user")
|
Jobs.enqueue(:send_system_message, user_id: id, message_type: "welcome_tl1_user")
|
||||||
end
|
end
|
||||||
|
|
||||||
def enqueue_welcome_moderator_message
|
def enqueue_staff_welcome_message(role)
|
||||||
return unless moderator
|
return unless staff?
|
||||||
Jobs.enqueue(:send_system_message, user_id: id, message_type: 'welcome_moderator')
|
|
||||||
|
Jobs.enqueue(
|
||||||
|
:send_system_message,
|
||||||
|
user_id: id,
|
||||||
|
message_type: 'welcome_staff',
|
||||||
|
message_options: {
|
||||||
|
role: role
|
||||||
|
}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def change_username(new_username, actor = nil)
|
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).
|
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:
|
welcome_staff:
|
||||||
title: "Welcome Moderator"
|
title: "Welcome Staff"
|
||||||
subject_template: "Congratulations, you’re now a moderator!"
|
subject_template: "Congratulations, you’re now a %{role}!"
|
||||||
text_body_template: |
|
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).
|
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:
|
welcome_invite:
|
||||||
|
@ -33,6 +33,7 @@ describe AdminConfirmation do
|
|||||||
expect(ac.performed_by).to eq(admin)
|
expect(ac.performed_by).to eq(admin)
|
||||||
expect(ac.target_user).to eq(user)
|
expect(ac.target_user).to eq(user)
|
||||||
expect(ac.token).to eq(@token)
|
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!
|
ac.email_confirmed!
|
||||||
|
|
||||||
user.reload
|
user.reload
|
||||||
|
@ -426,6 +426,7 @@ RSpec.describe Admin::UsersController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'updates the moderator flag' do
|
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"
|
put "/admin/users/#{another_user.id}/grant_moderation.json"
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
another_user.reload
|
another_user.reload
|
||||||
|
Reference in New Issue
Block a user