From 7a6b4406ef017bcb447c70758c5ccd0e4c8f1552 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 13 Oct 2022 12:47:55 +0200 Subject: [PATCH] remove redundant shadoban filters --- files/routes/front.py | 3 --- files/routes/posts.py | 21 +++++++++++---------- files/routes/search.py | 3 --- files/routes/users.py | 1 - 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/files/routes/front.py b/files/routes/front.py index cf3188b9f..404eddd29 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -112,9 +112,6 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false" word = word.replace('\\', '').replace('_', '\_').replace('%', '\%').strip() posts=posts.filter(not_(Submission.title.ilike(f'%{word}%'))) - if not (v and v.shadowbanned): - posts = posts.join(Submission.author).filter(User.shadowbanned == None) - posts = sort_objects(sort, posts, Submission, include_shadowbanned=(v and v.can_see_shadowbanned)) diff --git a/files/routes/posts.py b/files/routes/posts.py index eb5d56832..e06a8186f 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -166,10 +166,6 @@ def post_id(pid, anything=None, v=None, sub=None): blocking.c.target_id, blocked.c.target_id, ) - - if not (v and v.can_see_shadowbanned): - comments = comments.join(Comment.author).filter(User.shadowbanned == None) - comments=comments.filter(Comment.parent_submission == post.id, Comment.level < 10).join( votes, votes.c.comment_id == Comment.id, @@ -203,7 +199,11 @@ def post_id(pid, anything=None, v=None, sub=None): else: pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.stickied != None).all() - comments = g.db.query(Comment).join(Comment.author).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.level == 1, Comment.stickied == None) + comments = g.db.query(Comment).filter( + Comment.parent_submission == post.id, + Comment.level == 1, + Comment.stickied == None + ) comments = sort_objects(sort, comments, Comment, include_shadowbanned=False) @@ -290,10 +290,6 @@ def viewmore(v, pid, sort, offset): blocking.c.target_id, blocked.c.target_id, ).filter(Comment.parent_submission == pid, Comment.stickied == None, Comment.id.notin_(ids), Comment.level < 10) - - if not (v and v.can_see_shadowbanned): - comments = comments.join(Comment.author).filter(User.shadowbanned == None) - comments=comments.join( votes, votes.c.comment_id == Comment.id, @@ -323,7 +319,12 @@ def viewmore(v, pid, sort, offset): 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 = g.db.query(Comment).filter( + Comment.parent_submission == pid, + Comment.level == 1, + Comment.stickied == None, + Comment.id.notin_(ids) + ) comments = sort_objects(sort, comments, Comment, include_shadowbanned=False) diff --git a/files/routes/search.py b/files/routes/search.py index 6ea5c4fcd..cca7817b6 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -67,9 +67,6 @@ def searchposts(v): Submission.is_banned == False, Submission.private == False) - if v.admin_level < PERMS['USER_SHADOWBAN']: - posts = posts.filter(User.shadowbanned == None) - if 'author' in criteria: posts = posts.filter(Submission.ghost == False) author = get_user(criteria['author'], v=v, include_shadowbanned=False) diff --git a/files/routes/users.py b/files/routes/users.py index 1754a8fc0..c4e3c30e7 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -903,7 +903,6 @@ def u_username_comments(username, v=None): comments = comments.filter( Comment.is_banned == False, Comment.ghost == False, - comment_post_author.shadowbanned == None, Comment.deleted_utc == 0 )