From c4b5fe2913897a84666f5178cba56aa2575315b7 Mon Sep 17 00:00:00 2001 From: Michael House Date: Mon, 12 Sep 2022 06:26:10 -0500 Subject: [PATCH] Added filter for logged out users --- files/routes/posts.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/files/routes/posts.py b/files/routes/posts.py index 01580fe0f..0800354dd 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -165,10 +165,8 @@ def post_id(pid, anything=None, v=None, sub=None): if not (v and v.shadowbanned) and not (v and v.admin_level > 2): comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None) - if not v or v.admin_level < 2: - filter_clause = (Comment.filter_state != 'filtered') & (Comment.filter_state != 'removed') - if v: - filter_clause = filter_clause | (Comment.author_id == v.id) + if v.admin_level < 2: + filter_clause = ((Comment.filter_state != 'filtered') & (Comment.filter_state != 'removed')) | (Comment.author_id == v.id) comments = comments.filter(filter_clause) comments=comments.filter(Comment.parent_submission == post.id).join( @@ -225,6 +223,9 @@ def post_id(pid, anything=None, v=None, sub=None): elif sort == "bottom": comments = comments.order_by(Comment.upvotes - Comment.downvotes) + filter_clause = (Comment.filter_state != 'filtered') & (Comment.filter_state != 'removed') + comments = comments.filter(filter_clause) + comments = comments.all() offset = 0