From 8a2f4030c88022d38b19a6eed352f742908a4e4c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 6 Aug 2021 17:56:45 +0200 Subject: [PATCH] df --- files/routes/comments.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index 537765c03..61db7be8d 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -77,16 +77,27 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): for i in range(6 - context): if v: - blocking = v.blocking.subquery() - blocked = v.blocked.subquery() + votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery() + blocking = v.blocking.subquery() + + blocked = v.blocked.subquery() comments = g.db.query( Comment, + votes.c.vote_type, blocking.c.id, blocked.c.id, - ).filter( + ) + if v.admin_level >=4: + comments=comments.options(joinedload(Comment.oauth_app)) + + comments=comments.filter( Comment.parent_comment_id.in_(current_ids) + ).join( + votes, + votes.c.comment_id == Comment.id, + isouter=True ).join( blocking, blocking.c.target_id == Comment.author_id, @@ -116,8 +127,10 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): output = [] for c in comments: comment = c[0] - comment._is_blocking = c[1] or 0 - comment._is_blocked = c[2] or 0 + if comment.author and comment.author.shadowbanned and not (v and v.id == comment.author_id): 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: