refactor seeing shadowbanned shit (untested)

remotes/1693176582716663532/tmp_refs/heads/watchparty
Aevann1 2022-10-12 08:24:30 +02:00
parent 318a20250c
commit e1ee9a69e4
4 changed files with 11 additions and 5 deletions

View File

@ -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']

View File

@ -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(

View File

@ -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()

View File

@ -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');