mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 03:16:41 +08:00
FIX: only send user suspension emails if email message provided (#12666)
This makes behavior consistent with documentation: API: > Will send an email with this message when present Web UI: > Optionally, provide more information about the suspension and it will be emailed to the user
This commit is contained in:
parent
65647000a1
commit
045adb76f2
|
@ -124,12 +124,14 @@ class Admin::UsersController < Admin::AdminController
|
|||
end
|
||||
@user.logged_out
|
||||
|
||||
Jobs.enqueue(
|
||||
:critical_user_email,
|
||||
type: :account_suspended,
|
||||
user_id: @user.id,
|
||||
user_history_id: user_history.id
|
||||
)
|
||||
if message && !message.empty?
|
||||
Jobs.enqueue(
|
||||
:critical_user_email,
|
||||
type: :account_suspended,
|
||||
user_id: @user.id,
|
||||
user_history_id: user_history.id
|
||||
)
|
||||
end
|
||||
|
||||
DiscourseEvent.trigger(
|
||||
:user_suspended,
|
||||
|
|
|
@ -133,10 +133,13 @@ RSpec.describe Admin::UsersController do
|
|||
|
||||
it "works properly" do
|
||||
expect(user).not_to be_suspended
|
||||
put "/admin/users/#{user.id}/suspend.json", params: {
|
||||
suspend_until: 5.hours.from_now,
|
||||
reason: "because I said so"
|
||||
}
|
||||
|
||||
expect do
|
||||
put "/admin/users/#{user.id}/suspend.json", params: {
|
||||
suspend_until: 5.hours.from_now,
|
||||
reason: "because I said so"
|
||||
}
|
||||
end.to change { Jobs::CriticalUserEmail.jobs.size }.by(0)
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user