Skip to content

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

FIX: filter participation ignore small actions (#45304)

Bannon Tannerc38b12da3273
diff --git a/lib/topics_filter.rb b/lib/topics_filter.rb
index 3f3c321b64c..5ab624c069e 100644
--- a/lib/topics_filter.rb
+++ b/lib/topics_filter.rb
@@ -522,6 +522,7 @@ class TopicsFilter
WHERE p.topic_id = topics.id
AND #{column} IN (#{ids.join(",")})
AND p.deleted_at IS NULL
+ AND p.post_type <> #{Post.types[:small_action]}
#{whisper_condition("p")}
)
SQL
diff --git a/spec/lib/topics_filter_spec.rb b/spec/lib/topics_filter_spec.rb
index 0abb80f33f5..6733afe6755 100644
--- a/spec/lib/topics_filter_spec.rb
+++ b/spec/lib/topics_filter_spec.rb
@@ -323,6 +323,26 @@ RSpec.describe TopicsFilter do
expect(filtered("group:group1+group2")).not_to include(topic.id)
end
+ it "ignores small actions when matching participation" do
+ topic = Fabricate(:post, user: u3).topic
+ Fabricate(:small_action, topic:, user: u1)
+
+ expect(filtered("users:alice")).not_to include(topic.id)
+ expect(filtered("group:group1")).not_to include(topic.id)
+ expect(filtered("-group:group1")).to include(topic.id)
+ end
+
+ it "does not match a topic just because a group member changed its status" do
+ topic = Fabricate(:post, user: u3).topic
+ topic.update_status("closed", true, u1)
+ topic.update_status("closed", false, u1)
+
+ expect(topic.posts.where(post_type: Post.types[:small_action], user_id: u1.id)).to exist
+
+ expect(filtered("users:alice")).not_to include(topic.id)
+ expect(filtered("group:group1")).not_to include(topic.id)
+ end
+
context "with whispers" do
fab!(:whisperer_group, :group)
fab!(:whisperer_user) { Fabricate(:user).tap { |u| whisperer_group.add(u) } }
@@ -341,6 +361,14 @@ RSpec.describe TopicsFilter do
expect(ids).to include(topic_by_u1.id, topic_by_u1_and_u2.id), query
end
end
+
+ it "counts whisper participation for whisperers" do
+ %w[users:alice group:group1].each do |query|
+ ids = filtered(query, Guardian.new(whisperer_user))
+
+ expect(ids).to include(topic_with_whisper_only.id), query
+ end
+ end
end
end