remove redundant shadoban filters

master
Aevann1 2022-10-13 12:47:55 +02:00
parent fb150dab8e
commit 7a6b4406ef
4 changed files with 11 additions and 17 deletions

View File

@ -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))

View File

@ -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)

View File

@ -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)

View File

@ -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
)