A platform for community discussion. Free, open, simple.
FIX: whisper's presence channels (#30097)
Régis Hanol3e7f0867ea04
diff --git a/plugins/discourse-presence/plugin.rb b/plugins/discourse-presence/plugin.rbindex e3c4c430c02..036df3c94b3 100644--- a/plugins/discourse-presence/plugin.rb+++ b/plugins/discourse-presence/plugin.rb@@ -31,7 +31,7 @@ after_initialize doconfigelsif topic_id = channel_name[%r{/discourse-presence/whisper/(\d+)}, 1]Topic.find(topic_id) # Just ensure it exists- PresenceChannel::Config.new(allowed_group_ids: [::Group::AUTO_GROUPS[:staff]])+ PresenceChannel::Config.new(allowed_group_ids: SiteSetting.whispers_allowed_groups_map)elsif post_id = channel_name[%r{/discourse-presence/edit/(\d+)}, 1]post = Post.find(post_id)topic = Topic.find(post.topic_id)@@ -39,8 +39,14 @@ after_initialize doconfig = PresenceChannel::Config.newconfig.allowed_group_ids = [::Group::AUTO_GROUPS[:staff]]- # Locked and whisper posts are staff only- next config if post.locked? || post.whisper?+ # Locked posts are staff only+ next config if post.locked?++ # Whispers posts are for allowed whisper groups+ if post.whisper?+ config.allowed_group_ids += SiteSetting.whispers_allowed_groups_map+ next config+ endconfig.allowed_user_ids = [post.user_id]@@ -55,8 +61,8 @@ after_initialize doconfig.allowed_group_ids += SiteSetting.edit_wiki_post_allowed_groups_mapend- if !topic.private_message? && SiteSetting.edit_all_post_groups.present?- config.allowed_group_ids += SiteSetting.edit_all_post_groups.split("|").map(&:to_i)+ if !topic.private_message? && SiteSetting.edit_all_post_groups_map.present?+ config.allowed_group_ids += SiteSetting.edit_all_post_groups_mapendif SiteSetting.enable_category_group_moderation? && topic.categorydiff --git a/plugins/discourse-presence/spec/integration/presence_spec.rb b/plugins/discourse-presence/spec/integration/presence_spec.rbindex 6a88101dcde..789c1270809 100644--- a/plugins/discourse-presence/spec/integration/presence_spec.rb+++ b/plugins/discourse-presence/spec/integration/presence_spec.rb@@ -118,15 +118,20 @@ RSpec.describe "discourse-presence" doit "handles permissions for whispers" doc = PresenceChannel.new("/discourse-presence/whisper/#{public_topic.id}")expect(c.config.public).to eq(false)- expect(c.config.allowed_group_ids).to contain_exactly(Group::AUTO_GROUPS[:staff])+ expect(c.config.allowed_group_ids).to contain_exactly(+ *SiteSetting.whispers_allowed_groups_map,+ )expect(c.config.allowed_user_ids).to eq(nil)end- it "only allows staff when editing whispers" do+ it "correctly allows whisperers when editing whispers" dop = Fabricate(:whisper, topic: public_topic, user: admin)c = PresenceChannel.new("/discourse-presence/edit/#{p.id}")expect(c.config.public).to eq(false)- expect(c.config.allowed_group_ids).to contain_exactly(Group::AUTO_GROUPS[:staff])+ expect(c.config.allowed_group_ids).to contain_exactly(+ Group::AUTO_GROUPS[:staff],+ *SiteSetting.whispers_allowed_groups_map,+ )expect(c.config.allowed_user_ids).to eq(nil)end