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.rbindex f576475bf36..787515bc1ff 100644--- a/lib/topic_view.rb+++ b/lib/topic_view.rb@@ -902,14 +902,7 @@ class TopicViewdef 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))enddef filter_posts_by_post_number(post_number, asc)diff --git a/spec/lib/topic_view_spec.rb b/spec/lib/topic_view_spec.rbindex dfb49f39b30..9a1372d28cf 100644--- a/spec/lib/topic_view_spec.rb+++ b/spec/lib/topic_view_spec.rb@@ -538,7 +538,7 @@ RSpec.describe TopicView dop3 = 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).postsexpect(anon_posts.map(&:id)).to eq([p1.id, p3.id])