From 6df6054938bd1886387f702f1cb54cc151cc1a77 Mon Sep 17 00:00:00 2001 From: justcool393 Date: Fri, 7 Oct 2022 20:48:37 -0700 Subject: [PATCH] remove revert admin actions function --- files/helpers/const.py | 1 - files/routes/admin.py | 50 ----------------------------------- files/templates/userpage.html | 9 +------ 3 files changed, 1 insertion(+), 59 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index 24735dc68..e0e5217d4 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -165,7 +165,6 @@ PERMS = { # Minimum admin_level to perform action. 'ADMIN_ADD': 3, # note: explicitly disabled on rDrama 'ADMIN_REMOVE': 3, 'ADMIN_ADD_PERM_LEVEL': 2, # permission level given when user added via site - 'ADMIN_ACTIONS_REVERT': 3, 'ADMIN_MOP_VISIBLE': 2, 'ADMIN_HOME_VISIBLE': 2, 'DOMAINS_BAN': 3, diff --git a/files/routes/admin.py b/files/routes/admin.py index 4c096f9a2..fe0dac4de 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -247,56 +247,6 @@ def distribute(v, option_id): return {"message": f"Each winner has received {coinsperperson} coins!"} -@app.post("/@/revert_actions") -@limiter.limit("1/second;30/minute;200/hour;1000/day") -@admin_level_required(PERMS['ADMIN_ACTIONS_REVERT']) -def revert_actions(v, username): - user = get_user(username) - - ma = ModAction( - kind="revert", - user_id=v.id, - target_user_id=user.id - ) - g.db.add(ma) - - cutoff = int(time.time()) - 86400 - - posts = [x[0] for x in g.db.query(ModAction.target_submission_id).filter(ModAction.user_id == user.id, ModAction.created_utc > cutoff, ModAction.kind == 'ban_post').all()] - posts = g.db.query(Submission).filter(Submission.id.in_(posts)).all() - - comments = [x[0] for x in g.db.query(ModAction.target_comment_id).filter(ModAction.user_id == user.id, ModAction.created_utc > cutoff, ModAction.kind == 'ban_comment').all()] - comments = g.db.query(Comment).filter(Comment.id.in_(comments)).all() - - for item in posts + comments: - item.is_banned = False - item.ban_reason = None - item.is_approved = v.id - g.db.add(item) - - users = (x[0] for x in g.db.query(ModAction.target_user_id).filter(ModAction.user_id == user.id, ModAction.created_utc > cutoff, ModAction.kind.in_(('shadowban', 'ban_user'))).all()) - users = g.db.query(User).filter(User.id.in_(users)).all() - - for user in users: - user.shadowbanned = None - user.unban_utc = 0 - user.ban_reason = None - if user.is_banned: - user.is_banned = 0 - send_repeatable_notification(user.id, f"@{v.username} has unbanned you!") - g.db.add(user) - - for u in user.alts: - u.shadowbanned = None - u.unban_utc = 0 - u.ban_reason = None - if u.is_banned: - u.is_banned = 0 - send_repeatable_notification(u.id, f"@{v.username} has unbanned you!") - g.db.add(u) - - return {"message": f"@{user.username}'s admin actions has been reverted!"} - @app.post("/@/club_allow") @limiter.limit("1/second;30/minute;200/hour;1000/day") @admin_level_required(PERMS['USER_CLUB_ALLOW_BAN']) diff --git a/files/templates/userpage.html b/files/templates/userpage.html index 79e22bdb5..e81b27639 100644 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -226,9 +226,6 @@ {% if v.admin_level >= PERMS['ADMIN_REMOVE'] %} Remove admin {% endif %} - {% if v.admin_level >= PERMS['ADMIN_ACTIONS_REVERT'] %} - Revert admin actions - {% endif %}
@@ -496,11 +493,7 @@ {% if v.admin_level >= PERMS['ADMIN_REMOVE'] %} Remove admin {% endif %} - - {% if v.admin_level >= PERMS['ADMIN_ACTIONS_REVERT'] %} - Revert admin actions - {% endif %} - +