more shadowban refactor
parent
81b2e04ff7
commit
925ec12141
|
@ -461,7 +461,7 @@ class User(Base):
|
||||||
@cache.memoize(timeout=86400)
|
@cache.memoize(timeout=86400)
|
||||||
def userpagelisting(self, site=None, v=None, page=1, sort="new", t="all"):
|
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)
|
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,
|
Notification.user_id == self.id, Notification.read == False,
|
||||||
Comment.is_banned == False, Comment.deleted_utc == 0)
|
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)
|
notifs = notifs.join(Comment.author).filter(User.shadowbanned == None)
|
||||||
|
|
||||||
return notifs.count() + self.post_notifications_count + self.modaction_notifications_count
|
return notifs.count() + self.post_notifications_count + self.modaction_notifications_count
|
||||||
|
@ -618,7 +618,7 @@ class User(Base):
|
||||||
Comment.parent_submission == None,
|
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)
|
notifs = notifs.join(Comment.author).filter(User.shadowbanned == None)
|
||||||
|
|
||||||
return notifs.count()
|
return notifs.count()
|
||||||
|
|
|
@ -39,7 +39,7 @@ def get_user(username, v=None, graceful=False, rendered=False, include_blocks=Fa
|
||||||
|
|
||||||
user = user.one_or_none()
|
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)
|
if not graceful: abort(404)
|
||||||
else: return None
|
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)
|
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)
|
if not graceful: abort(404)
|
||||||
else: return None
|
else: return None
|
||||||
|
|
||||||
|
|
|
@ -350,9 +350,8 @@ def club_ban(v, username):
|
||||||
|
|
||||||
|
|
||||||
@app.get("/admin/shadowbanned")
|
@app.get("/admin/shadowbanned")
|
||||||
@auth_required
|
@admin_level_required(PERMS['USER_SHADOWBAN'])
|
||||||
def shadowbanned(v):
|
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()
|
users = g.db.query(User).filter(User.shadowbanned != None).order_by(User.shadowbanned).all()
|
||||||
return render_template("shadowbanned.html", v=v, users=users)
|
return render_template("shadowbanned.html", v=v, users=users)
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
|
||||||
comment = get_comment(cid, v=v)
|
comment = get_comment(cid, v=v)
|
||||||
if not comment.can_see(v): abort(403)
|
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)
|
abort(404)
|
||||||
|
|
||||||
if v and request.values.get("read"):
|
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,
|
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.join(Comment.author).filter(User.shadowbanned == None)
|
||||||
|
|
||||||
comments=comments.filter(
|
comments=comments.filter(
|
||||||
|
|
|
@ -167,7 +167,7 @@ def post_id(pid, anything=None, v=None, sub=None):
|
||||||
blocked.c.target_id,
|
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.join(Comment.author).filter(User.shadowbanned == None)
|
||||||
|
|
||||||
comments=comments.filter(Comment.parent_submission == post.id, Comment.level < 10).join(
|
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,
|
blocked.c.target_id,
|
||||||
).filter(Comment.parent_submission == pid, Comment.stickied == None, Comment.id.notin_(ids), Comment.level < 10)
|
).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(Comment.author).filter(User.shadowbanned == None)
|
||||||
|
|
||||||
comments=comments.join(
|
comments=comments.join(
|
||||||
|
|
Loading…
Reference in New Issue