diff --git a/files/classes/comment.py b/files/classes/comment.py index df6b27b34..8a349c5e1 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -227,19 +227,21 @@ class Comment(Base): if self.parent_comment_id: return f"t3_{self.parent_comment_id}" elif self.parent_submission: return f"t2_{self.parent_submission}" - @property - def replies(self): + def replies(self, user): if self.replies2 != None: return [x for x in self.replies2 if not x.author.shadowbanned] + author_id = None + if user: + author_id = user.id if not self.parent_submission: return sorted((x for x in self.child_comments if x.author - and x.filter_state not in ('filtered', 'removed') + and (x.filter_state not in ('filtered', 'removed') or x.author_id == author_id) and not x.author.shadowbanned), key=lambda x: x.created_utc) return sorted((x for x in self.child_comments if x.author and not x.author.shadowbanned - and x.filter_state not in ('filtered', 'removed') + and (x.filter_state not in ('filtered', 'removed') or x.author_id == author_id) and x.author_id not in (AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), key=lambda x: x.realupvotes, reverse=True) diff --git a/files/routes/posts.py b/files/routes/posts.py index 230d34c28..f84981597 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -282,10 +282,16 @@ def viewmore(v, pid, sort, offset): blocking.c.target_id, blocked.c.target_id, ).filter(Comment.parent_submission == pid, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), Comment.is_pinned == None, Comment.id.notin_(ids)) - + if not (v and v.shadowbanned) and not (v and v.admin_level > 2): comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None) - + + if not v or v.admin_level < 2: + filter_clause = (Comment.filter_state != 'filtered') & (Comment.filter_state != 'removed') + if v: + filter_clause = filter_clause | (Comment.author_id == v.id) + comments = comments.filter(filter_clause) + comments=comments.join( votes, votes.c.comment_id == Comment.id, diff --git a/files/templates/comments.html b/files/templates/comments.html index a32816665..a14cf0b79 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -55,7 +55,7 @@ {% if v and (v.shadowbanned or v.admin_level > 2) %} {% set replies=c.replies_ignoring_shadowbans %} {% else %} - {% set replies=c.replies %} + {% set replies=c.replies(v) %} {% endif %} {% if (c.is_banned or c.deleted_utc or c.is_blocking) and not (v and v.admin_level > 1) and not (v and v.id==c.author_id) %}