more shadowban refactor

remotes/1693176582716663532/tmp_refs/heads/watchparty
Aevann1 2022-10-12 08:53:32 +02:00
parent 81b2e04ff7
commit 925ec12141
5 changed files with 10 additions and 11 deletions

View File

@ -461,7 +461,7 @@ class User(Base):
@cache.memoize(timeout=86400)
def userpagelisting(self, site=None, v=None, page=1, sort="new", t="all"):
if self.shadowbanned and not (v and (v.admin_level >= PERMS['USER_SHADOWBAN'] or v.id == self.id)): return []
if self.shadowbanned and not (v and v.can_see_shadowbanned): return []
posts = g.db.query(Submission.id).filter_by(author_id=self.id, is_pinned=False)
@ -593,7 +593,7 @@ class User(Base):
Notification.user_id == self.id, Notification.read == False,
Comment.is_banned == False, Comment.deleted_utc == 0)
if not self.shadowbanned and self.admin_level < PERMS['USER_SHADOWBAN']:
if not self.can_see_shadowbanned:
notifs = notifs.join(Comment.author).filter(User.shadowbanned == None)
return notifs.count() + self.post_notifications_count + self.modaction_notifications_count
@ -618,7 +618,7 @@ class User(Base):
Comment.parent_submission == None,
)
if not self.shadowbanned and self.admin_level < PERMS['USER_SHADOWBAN']:
if not self.can_see_shadowbanned:
notifs = notifs.join(Comment.author).filter(User.shadowbanned == None)
return notifs.count()

View File

@ -39,7 +39,7 @@ def get_user(username, v=None, graceful=False, rendered=False, include_blocks=Fa
user = user.one_or_none()
if not user or (user.shadowbanned and not (include_shadowbanned or (v and (v.admin_level >= PERMS['USER_SHADOWBAN'] or v.shadowbanned)))):
if not user or (user.shadowbanned and not (include_shadowbanned or (v and v.can_see_shadowbanned))):
if not graceful: abort(404)
else: return None
@ -95,7 +95,7 @@ def get_account(id, v=None, graceful=False, include_blocks=False, include_shadow
user = g.db.get(User, id)
if not user or (user.shadowbanned and not (include_shadowbanned or (v and (v.admin_level >= PERMS['USER_SHADOWBAN'] or v.shadowbanned)))):
if not user or (user.shadowbanned and not (include_shadowbanned or (v and v.can_see_shadowbanned))):
if not graceful: abort(404)
else: return None

View File

@ -350,9 +350,8 @@ def club_ban(v, username):
@app.get("/admin/shadowbanned")
@auth_required
@admin_level_required(PERMS['USER_SHADOWBAN'])
def shadowbanned(v):
if not (v and v.admin_level >= PERMS['USER_SHADOWBAN']): abort(404)
users = g.db.query(User).filter(User.shadowbanned != None).order_by(User.shadowbanned).all()
return render_template("shadowbanned.html", v=v, users=users)

View File

@ -36,7 +36,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
comment = get_comment(cid, v=v)
if not comment.can_see(v): abort(403)
if comment.author.shadowbanned and not (v and v.shadowbanned) and not (v and v.admin_level >= PERMS['USER_SHADOWBAN']):
if comment.author.shadowbanned and not (v and v.can_see_shadowbanned):
abort(404)
if v and request.values.get("read"):
@ -86,7 +86,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
blocked.c.target_id,
)
if not (v and v.shadowbanned) and not (v and 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.filter(

View File

@ -167,7 +167,7 @@ def post_id(pid, anything=None, v=None, sub=None):
blocked.c.target_id,
)
if not (v and v.shadowbanned) and not (v and 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.filter(Comment.parent_submission == post.id, Comment.level < 10).join(
@ -289,7 +289,7 @@ def viewmore(v, pid, sort, offset):
blocked.c.target_id,
).filter(Comment.parent_submission == pid, Comment.stickied == None, Comment.id.notin_(ids), Comment.level < 10)
if not (v and v.shadowbanned) and not (v and 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(