mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FEATURE: Add TL1 to chat_allowed_groups by default (#19116)
By doing this, we will: * Have an open, but safe default People reach `@trust_level_1` pretty quickly, but `@trust_level_0` is still excluded by default, to limit new accounts joining and immediately spamming or otherwise abusing channels. * Make it easier to change the default By keeping `@staff` in the default, we make it easy for admins to remove `@trust_level_1` and optionally add additional groups to their liking.
This commit is contained in:
@ -6,7 +6,7 @@ chat:
|
|||||||
client: true
|
client: true
|
||||||
type: group_list
|
type: group_list
|
||||||
list_type: compact
|
list_type: compact
|
||||||
default: "3" # 3 is staff group id
|
default: "3|11" # 3: @staff, 11: @trust_level_1
|
||||||
allow_any: false
|
allow_any: false
|
||||||
refresh: true
|
refresh: true
|
||||||
needs_chat_seeded:
|
needs_chat_seeded:
|
||||||
@ -85,14 +85,14 @@ chat:
|
|||||||
hidden: true
|
hidden: true
|
||||||
client: true
|
client: true
|
||||||
direct_message_enabled_groups:
|
direct_message_enabled_groups:
|
||||||
default: "11" # auto group trust_level_1
|
default: "11" # @trust_level_1
|
||||||
type: group_list
|
type: group_list
|
||||||
client: true
|
client: true
|
||||||
allow_any: false
|
allow_any: false
|
||||||
refresh: true
|
refresh: true
|
||||||
validator: "DirectMessageEnabledGroupsValidator"
|
validator: "DirectMessageEnabledGroupsValidator"
|
||||||
chat_message_flag_allowed_groups:
|
chat_message_flag_allowed_groups:
|
||||||
default: "11" # auto group trust_level_1
|
default: "11" # @trust_level_1
|
||||||
type: group_list
|
type: group_list
|
||||||
client: true
|
client: true
|
||||||
allow_any: false
|
allow_any: false
|
||||||
|
@ -11,11 +11,6 @@ RSpec.describe Chat::GuardianExtensions do
|
|||||||
let(:guardian) { Guardian.new(user) }
|
let(:guardian) { Guardian.new(user) }
|
||||||
let(:staff_guardian) { Guardian.new(staff) }
|
let(:staff_guardian) { Guardian.new(staff) }
|
||||||
|
|
||||||
before do
|
|
||||||
SiteSetting.chat_allowed_groups = chat_group.id
|
|
||||||
chat_group.add(user)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "cannot chat if the user is not in the Chat.allowed_group_ids" do
|
it "cannot chat if the user is not in the Chat.allowed_group_ids" do
|
||||||
SiteSetting.chat_allowed_groups = ""
|
SiteSetting.chat_allowed_groups = ""
|
||||||
expect(guardian.can_chat?(user)).to eq(false)
|
expect(guardian.can_chat?(user)).to eq(false)
|
||||||
@ -26,6 +21,22 @@ RSpec.describe Chat::GuardianExtensions do
|
|||||||
expect(guardian.can_chat?(staff)).to eq(true)
|
expect(guardian.can_chat?(staff)).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "allows TL1 to chat by default and by extension higher trust levels" do
|
||||||
|
Group.refresh_automatic_groups!
|
||||||
|
expect(guardian.can_chat?(user)).to eq(true)
|
||||||
|
user.update!(trust_level: TrustLevel[3])
|
||||||
|
Group.refresh_automatic_groups!
|
||||||
|
expect(guardian.can_chat?(user)).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "allows user in specific group to chat" do
|
||||||
|
SiteSetting.chat_allowed_groups = chat_group.id
|
||||||
|
expect(guardian.can_chat?(user)).to eq(false)
|
||||||
|
chat_group.add(user)
|
||||||
|
user.reload
|
||||||
|
expect(guardian.can_chat?(user)).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
describe "chat channel" do
|
describe "chat channel" do
|
||||||
it "only staff can create channels" do
|
it "only staff can create channels" do
|
||||||
expect(guardian.can_create_chat_channel?).to eq(false)
|
expect(guardian.can_create_chat_channel?).to eq(false)
|
||||||
|
Reference in New Issue
Block a user