A platform for community discussion. Free, open, simple.
FIX: Include silence reason for auto-silenced users (#35898)
Krzysztof Kotlarek6185b0c8b1a0
diff --git a/app/controllers/admin/email_templates_controller.rb b/app/controllers/admin/email_templates_controller.rbindex 5e16dd60e2c..7d724fc8b69 100644--- a/app/controllers/admin/email_templates_controller.rb+++ b/app/controllers/admin/email_templates_controller.rb@@ -73,6 +73,7 @@ class Admin::EmailTemplatesController < Admin::AdminControllersystem_messages.user_added_to_group_as_membersystem_messages.user_added_to_group_as_ownersystem_messages.user_automatically_silenced+ system_messages.user_automatically_silenced_with_reasonsystem_messages.welcome_invitesystem_messages.welcome_staffsystem_messages.welcome_tl1_userdiff --git a/app/services/user_silencer.rb b/app/services/user_silencer.rbindex ba23c099c03..419ba36a0a1 100644--- a/app/services/user_silencer.rb+++ b/app/services/user_silencer.rb@@ -108,9 +108,12 @@ class UserSilencerGroupMessage.create(Group[:moderators].name,- :user_automatically_silenced,+ @opts[:reason] ? :user_automatically_silenced_with_reason : :user_automatically_silenced,user: @user,limit_once_per: false,+ message_params: {+ reason: @opts[:reason],+ },)endenddiff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 622e85832cb..445a16c4051 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -4041,7 +4041,20 @@ en:text_body_template: |This is an automated message.- The new user [%{username}](%{user_url}) was automatically silenced because multiple users flagged %{username}'s post(s).+ The new user [%{username}](%{user_url}) was automatically silenced.++ Please [review the flags](%{base_url}/review). If %{username} was incorrectly silenced from posting, click the unsilence button on [the admin page for this user](%{user_url}).++ This threshold can be changed via the `silence_new_user` site settings.+ user_automatically_silenced_with_reason:+ title: "User Automatically Silenced"+ subject_template: "New user %{username} silenced by community flags"+ text_body_template: |+ This is an automated message.++ The new user [%{username}](%{user_url}) was automatically silenced.++ Reason - %{reason}Please [review the flags](%{base_url}/review). If %{username} was incorrectly silenced from posting, click the unsilence button on [the admin page for this user](%{user_url}).diff --git a/spec/lib/new_post_manager_spec.rb b/spec/lib/new_post_manager_spec.rbindex 7604fb32e9b..1d0c0a774ff 100644--- a/spec/lib/new_post_manager_spec.rb+++ b/spec/lib/new_post_manager_spec.rb@@ -272,7 +272,9 @@ RSpec.describe NewPostManager do).and change { user.silence_reason }.to(I18n.t("user.new_user_typed_too_fast", locale: :en),).and change {- Topic.where("subtype = 'system_message' AND title LIKE '%silenced%'").count+ Topic.where(+ "subtype = 'system_message' AND title LIKE '%silenced%' AND excerpt LIKE '%Reason - New user typed too fast%'",+ ).count}.by(1)endend@@ -712,7 +714,9 @@ RSpec.describe NewPostManager do)expect { @result = manager.perform }.to change { user.silenced? }.to(true).and change {- Topic.where("subtype = 'system_message' AND title LIKE '%silenced%'").count+ Topic.where(+ "subtype = 'system_message' AND title LIKE '%silenced%' AND excerpt LIKE '%first email was flagged as spam%'",+ ).count}.by(1)expect(@result.action).to eq(:enqueued)end