Filter on other pages as well

This commit is contained in:
Julian Rota 2022-06-22 23:38:46 -04:00 committed by Ben Rog-Wilhelm
parent 420e3e1e8e
commit f736d660b6
3 changed files with 15 additions and 7 deletions

View file

@ -227,19 +227,21 @@ class Comment(Base):
if self.parent_comment_id: return f"t3_{self.parent_comment_id}" if self.parent_comment_id: return f"t3_{self.parent_comment_id}"
elif self.parent_submission: return f"t2_{self.parent_submission}" elif self.parent_submission: return f"t2_{self.parent_submission}"
@property def replies(self, user):
def replies(self):
if self.replies2 != None: return [x for x in self.replies2 if not x.author.shadowbanned] 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: if not self.parent_submission:
return sorted((x for x in self.child_comments return sorted((x for x in self.child_comments
if x.author 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), and not x.author.shadowbanned),
key=lambda x: x.created_utc) key=lambda x: x.created_utc)
return sorted((x for x in self.child_comments return sorted((x for x in self.child_comments
if x.author if x.author
and not x.author.shadowbanned 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)), and x.author_id not in (AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)),
key=lambda x: x.realupvotes, reverse=True) key=lambda x: x.realupvotes, reverse=True)

View file

@ -282,10 +282,16 @@ def viewmore(v, pid, sort, offset):
blocking.c.target_id, blocking.c.target_id,
blocked.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)) ).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): 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) 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( comments=comments.join(
votes, votes,
votes.c.comment_id == Comment.id, votes.c.comment_id == Comment.id,

View file

@ -55,7 +55,7 @@
{% if v and (v.shadowbanned or v.admin_level > 2) %} {% if v and (v.shadowbanned or v.admin_level > 2) %}
{% set replies=c.replies_ignoring_shadowbans %} {% set replies=c.replies_ignoring_shadowbans %}
{% else %} {% else %}
{% set replies=c.replies %} {% set replies=c.replies(v) %}
{% endif %} {% 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) %} {% 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) %}