From e5af46c4ae355b74f0f5a0c3607f88a9380fb8c4 Mon Sep 17 00:00:00 2001 From: TLSM Date: Thu, 13 Oct 2022 00:10:34 -0400 Subject: [PATCH] Fix shadow visibility logic. --- files/classes/comment.py | 2 +- files/classes/user.py | 4 ++-- files/routes/front.py | 4 ++-- files/routes/posts.py | 8 ++++---- files/routes/search.py | 4 ++-- files/routes/users.py | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 6de741271..a2a96b6eb 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -215,7 +215,7 @@ class Comment(Base): if not self.parent_submission: sort='old' return sort_objects(sort, replies, Comment, - include_shadowbanned=(not (v and v.can_see_shadowbanned))).all() + include_shadowbanned=(v and v.can_see_shadowbanned)).all() @property diff --git a/files/classes/user.py b/files/classes/user.py index 96c984004..97d909dfc 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -479,7 +479,7 @@ class User(Base): posts = apply_time_filter(t, posts, Submission) posts = sort_objects(sort, posts, Submission, - include_shadowbanned=(not (v and v.can_see_shadowbanned))) + include_shadowbanned=(v and v.can_see_shadowbanned)) posts = posts.offset(25 * (page - 1)).limit(26).all() @@ -980,4 +980,4 @@ class User(Base): @property @lazy def can_see_shadowbanned(self): - return self.shadowbanned or self.admin_level >= PERMS['USER_SHADOWBAN'] + return (self.admin_level >= PERMS['USER_SHADOWBAN']) or self.shadowbanned diff --git a/files/routes/front.py b/files/routes/front.py index e200142de..55fbb00c3 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -116,7 +116,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false" posts = posts.join(Submission.author).filter(User.shadowbanned == None) posts = sort_objects(sort, posts, Submission, - include_shadowbanned=(not (v and v.can_see_shadowbanned))) + include_shadowbanned=(v and v.can_see_shadowbanned)) if v: size = v.frontsize or 0 else: size = 25 @@ -237,7 +237,7 @@ def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all", gt=0, lt=0, comments = apply_time_filter(t, comments, Comment) comments = sort_objects(sort, comments, Comment, - include_shadowbanned=(not (v and v.can_see_shadowbanned))) + include_shadowbanned=(v and v.can_see_shadowbanned)) comments = comments.offset(25 * (page - 1)).limit(26).all() return [x[0] for x in comments] diff --git a/files/routes/posts.py b/files/routes/posts.py index 4df9ed517..eb5d56832 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -197,7 +197,7 @@ def post_id(pid, anything=None, v=None, sub=None): comments = comments.filter(Comment.level == 1, Comment.stickied == None) comments = sort_objects(sort, comments, Comment, - include_shadowbanned=(not (v and v.can_see_shadowbanned))) + include_shadowbanned=(v and v.can_see_shadowbanned)) comments = [c[0] for c in comments.all()] else: @@ -206,7 +206,7 @@ def post_id(pid, anything=None, v=None, sub=None): comments = g.db.query(Comment).join(Comment.author).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.level == 1, Comment.stickied == None) comments = sort_objects(sort, comments, Comment, - include_shadowbanned=(not (v and v.can_see_shadowbanned))) + include_shadowbanned=False) comments = comments.all() @@ -319,14 +319,14 @@ def viewmore(v, pid, sort, offset): comments = comments.filter(Comment.level == 1) comments = sort_objects(sort, comments, Comment, - include_shadowbanned=(not (v and v.can_see_shadowbanned))) + include_shadowbanned=(v and v.can_see_shadowbanned)) comments = [c[0] for c in comments.all()] else: comments = g.db.query(Comment).join(Comment.author).filter(User.shadowbanned == None, Comment.parent_submission == pid, Comment.level == 1, Comment.stickied == None, Comment.id.notin_(ids)) comments = sort_objects(sort, comments, Comment, - include_shadowbanned=(not (v and v.can_see_shadowbanned))) + include_shadowbanned=False) comments = comments.offset(offset).all() diff --git a/files/routes/search.py b/files/routes/search.py index 715ef768e..6ea5c4fcd 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -146,7 +146,7 @@ def searchposts(v): posts = apply_time_filter(t, posts, Submission) posts = sort_objects(sort, posts, Submission, - include_shadowbanned=(not (v and v.can_see_shadowbanned))) + include_shadowbanned=(v and v.can_see_shadowbanned)) total = posts.count() @@ -250,7 +250,7 @@ def searchcomments(v): comments = comments.filter(Comment.created_utc < before) comments = sort_objects(sort, comments, Comment, - include_shadowbanned=(not (v and v.can_see_shadowbanned))) + include_shadowbanned=(v and v.can_see_shadowbanned)) total = comments.count() diff --git a/files/routes/users.py b/files/routes/users.py index 9ef49d1b1..1754a8fc0 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -910,7 +910,7 @@ def u_username_comments(username, v=None): comments = apply_time_filter(t, comments, Comment) comments = sort_objects(sort, comments, Comment, - include_shadowbanned=(not (v and v.can_see_shadowbanned))) + include_shadowbanned=(v and v.can_see_shadowbanned)) comments = comments.offset(25 * (page - 1)).limit(26).all() ids = [x.id for x in comments]