FIX: prevents admins to be silenced (#21854)

Currently in chat it was possible to have TL4 users to flag admins and silence them, this change should ensure it's never possible.
This commit is contained in:
Joffrey JAFFEUX 2023-06-01 08:36:11 +02:00 committed by GitHub
parent 96a2893284
commit 9ba333808f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -87,6 +87,7 @@ module Chat
return if reviewable.score <= Chat::ReviewableMessage.score_to_silence_user
user = reviewable.target_created_by
return if user.admin?
return unless user
return if user.silenced?

View File

@ -369,6 +369,18 @@ describe Chat::ReviewQueue do
expect(message_poster.reload.silenced?).to eq(false)
end
context "when the target is an admin" do
it "does not silence the user" do
SiteSetting.chat_auto_silence_from_flags_duration = 1
flagger.update!(trust_level: TrustLevel[4]) # Increase Score due to TL Bonus.
message_poster.update!(admin: true)
queue.flag_message(message, guardian, ReviewableScore.types[:off_topic])
expect(message_poster.reload.silenced?).to eq(false)
end
end
end
context "when flagging a DM" do