Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Add TL1 to chat_allowed_groups by default (#19116)

Martin Brennan05b740036e90
diff --git a/plugins/chat/config/settings.yml b/plugins/chat/config/settings.yml
index 405d1f43a8e..bcf2177bc2b 100644
--- a/plugins/chat/config/settings.yml
+++ b/plugins/chat/config/settings.yml
@@ -6,7 +6,7 @@ chat:
client: true
type: group_list
list_type: compact
- default: "3" # 3 is staff group id
+ default: "3|11" # 3: @staff, 11: @trust_level_1
allow_any: false
refresh: true
needs_chat_seeded:
@@ -85,14 +85,14 @@ chat:
hidden: true
client: true
direct_message_enabled_groups:
- default: "11" # auto group trust_level_1
+ default: "11" # @trust_level_1
type: group_list
client: true
allow_any: false
refresh: true
validator: "DirectMessageEnabledGroupsValidator"
chat_message_flag_allowed_groups:
- default: "11" # auto group trust_level_1
+ default: "11" # @trust_level_1
type: group_list
client: true
allow_any: false
diff --git a/plugins/chat/spec/lib/guardian_extensions_spec.rb b/plugins/chat/spec/lib/guardian_extensions_spec.rb
index 0afc6a00707..e0d7bfa2de0 100644
--- a/plugins/chat/spec/lib/guardian_extensions_spec.rb
+++ b/plugins/chat/spec/lib/guardian_extensions_spec.rb
@@ -11,11 +11,6 @@ RSpec.describe Chat::GuardianExtensions do
let(:guardian) { Guardian.new(user) }
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
SiteSetting.chat_allowed_groups = ""
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)
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
it "only staff can create channels" do
expect(guardian.can_create_chat_channel?).to eq(false)