Skip to content

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

SECURITY: Don't display user's old whispers if not in allowed group

Alan Guo Xiang Tan0b1dd0455014
diff --git a/lib/topic_view.rb b/lib/topic_view.rb
index f576475bf36..787515bc1ff 100644
--- a/lib/topic_view.rb
+++ b/lib/topic_view.rb
@@ -902,14 +902,7 @@ class TopicView
def filter_post_types(posts)
return posts.where(post_type: Post.types[:regular]) if @only_regular
-
- visible_types = Topic.visible_post_types(@user)
-
- if @user.present?
- posts.where("posts.user_id = ? OR post_type IN (?)", @user.id, visible_types)
- else
- posts.where(post_type: visible_types)
- end
+ posts.where(post_type: Topic.visible_post_types(@user))
end
def filter_posts_by_post_number(post_number, asc)
diff --git a/spec/lib/topic_view_spec.rb b/spec/lib/topic_view_spec.rb
index dfb49f39b30..9a1372d28cf 100644
--- a/spec/lib/topic_view_spec.rb
+++ b/spec/lib/topic_view_spec.rb
@@ -538,7 +538,7 @@ RSpec.describe TopicView do
p3 = Fabricate(:post, topic: topic, user: evil_trout)
ch_posts = TopicView.new(topic.id, evil_trout).posts
- expect(ch_posts.map(&:id)).to eq([p1.id, p2.id, p3.id])
+ expect(ch_posts.map(&:id)).to eq([p1.id, p3.id])
anon_posts = TopicView.new(topic.id).posts
expect(anon_posts.map(&:id)).to eq([p1.id, p3.id])