mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
FIX: Skip sending PM email for user silence (#12240)
We were sending 2 emails for user silencing if a message was provided in the UI. Also always send email for user silence and user suspend with reason regardless of whether message provided.
This commit is contained in:
parent
09b05c4f96
commit
6b4d066834
@ -124,14 +124,12 @@ class Admin::UsersController < Admin::AdminController
|
|||||||
end
|
end
|
||||||
@user.logged_out
|
@user.logged_out
|
||||||
|
|
||||||
if message.present?
|
|
||||||
Jobs.enqueue(
|
Jobs.enqueue(
|
||||||
:critical_user_email,
|
:critical_user_email,
|
||||||
type: :account_suspended,
|
type: :account_suspended,
|
||||||
user_id: @user.id,
|
user_id: @user.id,
|
||||||
user_history_id: user_history.id
|
user_history_id: user_history.id
|
||||||
)
|
)
|
||||||
end
|
|
||||||
|
|
||||||
DiscourseEvent.trigger(
|
DiscourseEvent.trigger(
|
||||||
:user_suspended,
|
:user_suspended,
|
||||||
@ -345,7 +343,7 @@ class Admin::UsersController < Admin::AdminController
|
|||||||
keep_posts: true,
|
keep_posts: true,
|
||||||
post_id: params[:post_id]
|
post_id: params[:post_id]
|
||||||
)
|
)
|
||||||
if silencer.silence && message.present?
|
if silencer.silence
|
||||||
Jobs.enqueue(
|
Jobs.enqueue(
|
||||||
:critical_user_email,
|
:critical_user_email,
|
||||||
type: :account_silenced,
|
type: :account_silenced,
|
||||||
|
@ -144,7 +144,6 @@ class UserNotifications < ActionMailer::Base
|
|||||||
template: "user_notifications.account_silenced",
|
template: "user_notifications.account_silenced",
|
||||||
locale: user_locale(user),
|
locale: user_locale(user),
|
||||||
reason: user_history.details,
|
reason: user_history.details,
|
||||||
message: user_history.context,
|
|
||||||
silenced_till: I18n.l(user.silenced_till, format: :long)
|
silenced_till: I18n.l(user.silenced_till, format: :long)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@ -159,7 +158,6 @@ class UserNotifications < ActionMailer::Base
|
|||||||
template: "user_notifications.account_suspended",
|
template: "user_notifications.account_suspended",
|
||||||
locale: user_locale(user),
|
locale: user_locale(user),
|
||||||
reason: user_history.details,
|
reason: user_history.details,
|
||||||
message: user_history.context,
|
|
||||||
suspended_till: I18n.l(user.suspended_till, format: :long)
|
suspended_till: I18n.l(user.suspended_till, format: :long)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -61,6 +61,7 @@ class UserSilencer
|
|||||||
silence_message_params: silence_message_params
|
silence_message_params: silence_message_params
|
||||||
)
|
)
|
||||||
|
|
||||||
|
silence_message_params.merge!(post_alert_options: { skip_send_email: true })
|
||||||
SystemMessage.create(@user, message_type, silence_message_params)
|
SystemMessage.create(@user, message_type, silence_message_params)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
@ -3643,9 +3643,7 @@ en:
|
|||||||
text_body_template: |
|
text_body_template: |
|
||||||
You have been suspended from the forum until %{suspended_till}.
|
You have been suspended from the forum until %{suspended_till}.
|
||||||
|
|
||||||
%{reason}
|
Reason - %{reason}
|
||||||
|
|
||||||
%{message}
|
|
||||||
|
|
||||||
account_silenced:
|
account_silenced:
|
||||||
title: "Account Silenced"
|
title: "Account Silenced"
|
||||||
@ -3653,9 +3651,7 @@ en:
|
|||||||
text_body_template: |
|
text_body_template: |
|
||||||
You have been silenced from the forum until %{silenced_till}.
|
You have been silenced from the forum until %{silenced_till}.
|
||||||
|
|
||||||
%{reason}
|
Reason - %{reason}
|
||||||
|
|
||||||
%{message}
|
|
||||||
|
|
||||||
account_exists:
|
account_exists:
|
||||||
title: "Account already exists"
|
title: "Account already exists"
|
||||||
|
@ -39,7 +39,8 @@ class SystemMessage
|
|||||||
target_usernames: @recipient.username,
|
target_usernames: @recipient.username,
|
||||||
target_group_names: target_group_names,
|
target_group_names: target_group_names,
|
||||||
subtype: TopicSubtype.system_message,
|
subtype: TopicSubtype.system_message,
|
||||||
skip_validations: true)
|
skip_validations: true,
|
||||||
|
post_alert_options: params[:post_alert_options])
|
||||||
|
|
||||||
post = I18n.with_locale(@recipient.effective_locale) { creator.create }
|
post = I18n.with_locale(@recipient.effective_locale) { creator.create }
|
||||||
|
|
||||||
|
@ -33,6 +33,13 @@ describe UserSilencer do
|
|||||||
expect(count).to eq(1)
|
expect(count).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "skips sending the email for the silence PM via post alert" do
|
||||||
|
NotificationEmailer.enable
|
||||||
|
Jobs.run_immediately!
|
||||||
|
UserSilencer.silence(user, admin)
|
||||||
|
expect(ActionMailer::Base.deliveries.size).to eq(0)
|
||||||
|
end
|
||||||
|
|
||||||
it 'does not hide posts for tl1' do
|
it 'does not hide posts for tl1' do
|
||||||
user.update!(trust_level: 1)
|
user.update!(trust_level: 1)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user