diff --git a/files/classes/user.py b/files/classes/user.py index 916dd898d5..88f575b1de 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -1264,7 +1264,7 @@ class User(Base): @property @lazy def can_see_shadowbanned(self): - return (self.admin_level >= PERMS['USER_SHADOWBAN']) + return (self.can_see_shadowbanned) @property @lazy diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 5be756c3fd..88f34d92ed 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -227,7 +227,7 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None, followers_pi def push_notif(uids, title, body, url_or_comment): if hasattr(g, 'v') and g.v and g.v.shadowbanned: - uids = [x[0] for x in g.db.query(User.id).filter(User.id.in_(uids), User.admin_level >= PERMS['USER_SHADOWBAN']).all()] + uids = [x[0] for x in g.db.query(User.id).filter(User.id.in_(uids), User.can_see_shadowbanned).all()] if not uids: return diff --git a/files/routes/comments.py b/files/routes/comments.py index e9e5999d23..6ee4577f45 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -374,7 +374,7 @@ def comment(v): notify_users.add(parent_user.id) if v.shadowbanned: - notify_users = [x[0] for x in g.db.query(User.id).filter(User.id.in_(notify_users), User.admin_level >= PERMS['USER_SHADOWBAN']).all()] + notify_users = [x[0] for x in g.db.query(User.id).filter(User.id.in_(notify_users), User.can_see_shadowbanned).all()] for x in notify_users-BOT_IDs: n = Notification(comment_id=c.id, user_id=x) @@ -727,7 +727,7 @@ def edit_comment(cid, v): alert_everyone(c.id) else: if v.shadowbanned: - notify_users = [x[0] for x in g.db.query(User.id).filter(User.id.in_(notify_users), User.admin_level >= PERMS['USER_SHADOWBAN']).all()] + notify_users = [x[0] for x in g.db.query(User.id).filter(User.id.in_(notify_users), User.can_see_shadowbanned).all()] for x in notify_users-BOT_IDs: notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=x).one_or_none() diff --git a/files/routes/notifications.py b/files/routes/notifications.py index 0858c6c787..9906e1f29a 100644 --- a/files/routes/notifications.py +++ b/files/routes/notifications.py @@ -300,7 +300,7 @@ def notifications_reddit(v): def notifications(v): page = get_page() - if not session.get("GLOBAL") and v.admin_level < PERMS['USER_SHADOWBAN'] and not request.values.get('nr'): + if not session.get("GLOBAL") and not v.can_see_shadowbanned and not request.values.get('nr'): unread_and_inaccessible = g.db.query(Notification).join(Notification.comment).join(Comment.author).filter( Notification.user_id == v.id, Notification.read == False, @@ -324,7 +324,7 @@ def notifications(v): not_(and_(Comment.sentto != None, Comment.sentto == MODMAIL_ID, User.is_muted)) ) - if v.admin_level < PERMS['USER_SHADOWBAN']: + if not v.can_see_shadowbanned: comments = comments.filter( Comment.is_banned == False, Comment.deleted_utc == 0, diff --git a/files/routes/static.py b/files/routes/static.py index 40c2092de0..782e45e578 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -184,7 +184,7 @@ def log(v): kind = request.values.get("kind") - if v.admin_level >= PERMS['USER_SHADOWBAN']: + if v.can_see_shadowbanned: if v.admin_level >= PERMS['PROGSTACK']: types = MODACTION_TYPES else: @@ -197,7 +197,7 @@ def log(v): total = 0 else: actions = g.db.query(ModAction) - if v.admin_level < PERMS['USER_SHADOWBAN']: + if not v.can_see_shadowbanned: actions = actions.filter(ModAction.kind.notin_(MODACTION_PRIVILEGED_TYPES)) if v.admin_level < PERMS['PROGSTACK']: actions = actions.filter(ModAction.kind.notin_(MODACTION_PRIVILEGED__TYPES)) @@ -226,12 +226,12 @@ def log_item(id, v): if not action: abort(404) - if action.kind in MODACTION_PRIVILEGED_TYPES and v.admin_level < PERMS['USER_SHADOWBAN']: + if action.kind in MODACTION_PRIVILEGED_TYPES and not v.can_see_shadowbanned: abort(404) admins = [x[0] for x in g.db.query(User.username).filter(User.admin_level >= PERMS['ADMIN_MOP_VISIBLE'])] - if v.admin_level >= PERMS['USER_SHADOWBAN']: + if v.can_see_shadowbanned: if v.admin_level >= PERMS['PROGSTACK']: types = MODACTION_TYPES else: diff --git a/files/routes/users.py b/files/routes/users.py index 8992fd646d..6106df46d7 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -891,7 +891,7 @@ def u_username_wall(v, username): is_following = v and u.has_follower(v) - if v and v.id != u.id and v.admin_level < PERMS['USER_SHADOWBAN'] and not session.get("GLOBAL"): + if v and v.id != u.id and not v.can_see_shadowbanned and not session.get("GLOBAL"): gevent.spawn(_add_profile_view, v.id, u.id) page = get_page() @@ -938,7 +938,7 @@ def u_username_wall_comment(v, username, cid): is_following = v and u.has_follower(v) - if v and v.id != u.id and v.admin_level < PERMS['USER_SHADOWBAN'] and not session.get("GLOBAL"): + if v and v.id != u.id and not v.can_see_shadowbanned and not session.get("GLOBAL"): gevent.spawn(_add_profile_view, v.id, u.id) if v and request.values.get("read"): @@ -983,7 +983,7 @@ def u_username(v, username): abort(403, f"@{u.username}'s userpage is private") return render_template("userpage/private.html", u=u, v=v, is_following=is_following), 403 - if v and v.id != u.id and v.admin_level < PERMS['USER_SHADOWBAN'] and not session.get("GLOBAL"): + if v and v.id != u.id and not v.can_see_shadowbanned and not session.get("GLOBAL"): gevent.spawn(_add_profile_view, v.id, u.id) sort = request.values.get("sort", "new") @@ -1050,7 +1050,7 @@ def u_username_comments(username, v): abort(403, f"@{u.username}'s userpage is private") return render_template("userpage/private.html", u=u, v=v, is_following=is_following), 403 - if v and v.id != u.id and v.admin_level < PERMS['USER_SHADOWBAN'] and not session.get("GLOBAL"): + if v and v.id != u.id and not v.can_see_shadowbanned and not session.get("GLOBAL"): gevent.spawn(_add_profile_view, v.id, u.id) page = get_page() diff --git a/files/routes/votes.py b/files/routes/votes.py index 6f967664c2..06672f3f62 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -197,7 +197,7 @@ def vote_info_get(v, link): if thing.ghost and v.admin_level < PERMS['SEE_GHOST_VOTES']: abort(403) - if thing.author.shadowbanned and not (v and v.admin_level >= PERMS['USER_SHADOWBAN']): + if thing.author.shadowbanned and not (v and v.can_see_shadowbanned): abort(500) if isinstance(thing, Post): diff --git a/files/templates/admin/admin_home.html b/files/templates/admin/admin_home.html index b1f030ce61..e31f9e26af 100644 --- a/files/templates/admin/admin_home.html +++ b/files/templates/admin/admin_home.html @@ -57,7 +57,7 @@

Users