FIX: Moderator notifications when new post auto-silences a user (#35403)

When a user is auto-silenced because they receive enough spam flag, we notify moderators (given the notify_mods_when_user_silenced is enabled).

However, when a user is auto-silenced for other reasons, e.g. typing too fast, we don't send this notification.

This commit:

- Lifts the notification logic into a new UserSilencer#auto_silence method, which delegates 99% of its work to UserSilencer#silence.
- Uses this new method in places where users are auto-silenced.
This commit is contained in:
Ted Johansson
2025-10-15 16:07:56 +08:00
committed by GitHub
parent ea0555eedf
commit 69dfdf5084
5 changed files with 58 additions and 34 deletions
+3 -3
View File
@@ -178,21 +178,21 @@ class NewPostManager
I18n.with_locale(SiteSetting.default_locale) do
if is_fast_typer?(manager)
UserSilencer.silence(
UserSilencer.auto_silence(
manager.user,
Discourse.system_user,
keep_posts: true,
reason: I18n.t("user.new_user_typed_too_fast"),
)
elsif auto_silence?(manager) || matches_auto_silence_regex?(manager)
UserSilencer.silence(
UserSilencer.auto_silence(
manager.user,
Discourse.system_user,
keep_posts: true,
reason: I18n.t("user.content_matches_auto_silence_regex"),
)
elsif reason == :email_spam && is_first_post?(manager)
UserSilencer.silence(
UserSilencer.auto_silence(
manager.user,
Discourse.system_user,
keep_posts: true,