diff --git a/files/classes/user.py b/files/classes/user.py index 15c24b7df..0547c4fe6 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -775,8 +775,8 @@ class User(Base): 'bannerurl': self.banner_url, 'bio_html': self.bio_html_eager, 'coins': self.coins, - 'post_count': 0 if self.shadowbanned and not (v and (v.shadowbanned or v.admin_level >= PERMS['USER_SHADOWBAN'])) else self.post_count, - 'comment_count': 0 if self.shadowbanned and not (v and (v.shadowbanned or v.admin_level >= PERMS['USER_SHADOWBAN'])) else self.comment_count, + 'post_count': 0 if self.shadowbanned and not (v and v.can_see_shadowbanned) else self.post_count, + 'comment_count': 0 if self.shadowbanned and not (v and v.can_see_shadowbanned) else self.comment_count, 'badges': [x.path for x in self.badges], } @@ -967,3 +967,8 @@ class User(Base): return name return f'((({self.username})))' return self.username + + @property + @lazy + def can_see_shadowbanned(self): + return self.shadowbanned or self.admin_level >= PERMS['USER_SHADOWBAN'] diff --git a/files/helpers/get.py b/files/helpers/get.py index 58710d4a9..6e0bee72c 100644 --- a/files/helpers/get.py +++ b/files/helpers/get.py @@ -264,7 +264,7 @@ def get_comments(cids, v=None, load_parent=False): blocked.c.target_id, ).filter(Comment.id.in_(cids)) - if not (v and (v.shadowbanned or v.admin_level >= PERMS['USER_SHADOWBAN'])): + if not (v and v.can_see_shadowbanned): comments = comments.join(Comment.author).filter(User.shadowbanned == None) comments = comments.join( diff --git a/files/routes/notifications.py b/files/routes/notifications.py index f76e31196..207bbe136 100644 --- a/files/routes/notifications.py +++ b/files/routes/notifications.py @@ -258,7 +258,7 @@ def notifications(v): or_(Comment.sentto == None, Comment.sentto == 2), ).order_by(Notification.created_utc.desc()) - if not (v and (v.shadowbanned or v.admin_level >= PERMS['NOTIFICATIONS_FROM_SHADOWBANNED_USERS'])): + if not (v and v.can_see_shadowbanned): comments = comments.join(Comment.author).filter(User.shadowbanned == None) comments = comments.offset(25 * (page - 1)).limit(26).all() diff --git a/files/templates/comments.html b/files/templates/comments.html index 020529251..f5825a042 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -21,7 +21,7 @@ {% set score=ups-downs %} {% if render_replies %} - {% if v and (v.shadowbanned or v.admin_level >= PERMS['USER_SHADOWBAN']) %} + {% if v and v.can_see_shadowbanned %} {% set replies=c.replies3(sort) %} {% else %} {% set replies=c.replies(sort) %} @@ -850,6 +850,7 @@ btn.innerHTML = "Requesting..."; const form = new FormData(); form.append("formkey", formkey()); + form.append("sort", "{{sort}}"); const xhr = new XMLHttpRequest(); xhr.open("get", `/morecomments/${cid}`); xhr.setRequestHeader('xhr', 'xhr');