FEATURE: Allow staff to flag chat messages (#18919)

This commit is contained in:
Rafael dos Santos Silva 2022-11-22 12:14:15 -03:00 committed by GitHub
parent 2eee6fb644
commit c18453e38c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -95,6 +95,7 @@ module Chat::GuardianExtensions
def can_flag_chat_messages?
return false if @user.silenced?
return true if @user.staff?
@user.in_any_groups?(SiteSetting.chat_message_flag_allowed_groups_map)
end

View File

@ -143,6 +143,23 @@ RSpec.describe Chat::GuardianExtensions do
end
end
describe "#can_flag_chat_message?" do
let!(:message) { Fabricate(:chat_message, chat_channel: channel) }
before { SiteSetting.chat_message_flag_allowed_groups = "" }
context "when user isn't staff" do
it "returns false" do
expect(guardian.can_flag_chat_message?(message)).to eq(false)
end
end
context "when user is staff" do
it "returns true" do
expect(staff_guardian.can_flag_chat_message?(message)).to eq(true)
end
end
end
describe "#can_moderate_chat?" do
context "for category channel" do
fab!(:category) { Fabricate(:category, read_restricted: true) }