This commit is contained in:
Aevann1 2021-09-14 20:18:28 +02:00
parent 1a76d2ec29
commit 0a769c7d4b
3 changed files with 22 additions and 20 deletions

View file

@ -192,7 +192,7 @@ def get_comment(i, v=None, graceful=False, **kwargs):
return comment
def get_comments(cids, v=None, load_parent=False, shadowbanned=False):
def get_comments(cids, v=None, load_parent=False):
if not cids: return []
@ -212,6 +212,9 @@ def get_comments(cids, v=None, load_parent=False, shadowbanned=False):
blocked.c.id,
).filter(Comment.id.in_(cids))
if not (v and v.shadowbanned) and not (v and v.admin_level == 6):
comments = comments.join(Comment.author).filter(User.shadowbanned == False)
comments = comments.join(
votes,
votes.c.comment_id == Comment.id,
@ -229,14 +232,13 @@ def get_comments(cids, v=None, load_parent=False, shadowbanned=False):
output = []
for c in comments:
comment = c[0]
if comment.author and comment.author.shadowbanned and v.id != comment.author_id and not (shadowbanned and v.admin_level==6): continue
comment.voted = c[1] or 0
comment._is_blocking = c[2] or 0
comment._is_blocked = c[3] or 0
output.append(comment)
else:
output = g.db.query(Comment).filter(Comment.id.in_(cids)).all()
output = g.db.query(Comment).join(Comment.author).filter(Comment.id.in_(cids), User.shadowbanned == False).all()
if load_parent:
parents = [x.parent_comment_id for x in output if x.parent_comment_id]