sffsd
This commit is contained in:
parent
64a851a77e
commit
525f121e24
16 changed files with 55 additions and 86 deletions
|
@ -49,28 +49,35 @@ def truescore(v):
|
|||
|
||||
@app.post("/@<username>/revert_actions")
|
||||
@limiter.limit("1/second")
|
||||
@admin_level_required(2)
|
||||
@admin_level_required(3)
|
||||
@validate_formkey
|
||||
def revert_actions(v, username):
|
||||
if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.admin_level > 2) or ('rama' not in request.host and 'pcm' not in request.host):
|
||||
user = get_user(username)
|
||||
if not user: abort(404)
|
||||
user = get_user(username)
|
||||
if not user: abort(404)
|
||||
|
||||
cutoff = int(time.time()) - 86400
|
||||
|
||||
items = g.db.query(Submission).filter_by(removed_by=user.id).all() + g.db.query(Comment).filter_by(removed_by=user.id).all()
|
||||
posts = (x[0] for x in g.db.query(ModAction.target_submission_id).filter(ModAction.user_id == user.id, ModAction.created_utc > cutoff, Mod.action.kind == 'ban_post').all())
|
||||
comments = (x[0] for x in g.db.query(ModAction.target_comment_id).filter(ModAction.user_id == user.id, ModAction.created_utc > cutoff, Mod.action.kind == 'ban_comment').all())
|
||||
for item in posts + comments:
|
||||
item.is_banned = False
|
||||
g.db.add(item)
|
||||
|
||||
for item in items:
|
||||
item.is_banned = False
|
||||
item.removed_by = None
|
||||
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, Mod.action.kind.in_['shadowban', 'ban_user']).all())
|
||||
for user in users:
|
||||
user.shadowbanned = None
|
||||
user.is_banned = 0
|
||||
user.unban_utc = 0
|
||||
user.ban_evade = 0
|
||||
g.db.add(user)
|
||||
for u in user.alts:
|
||||
u.shadowbanned = None
|
||||
u.is_banned = 0
|
||||
u.unban_utc = 0
|
||||
u.ban_evade = 0
|
||||
g.db.add(u)
|
||||
|
||||
users = g.db.query(User).filter_by(is_banned=user.id).all()
|
||||
for user in users:
|
||||
user.is_banned = 0
|
||||
user.unban_utc = 0
|
||||
user.ban_evade = 0
|
||||
g.db.add(user)
|
||||
|
||||
g.db.commit()
|
||||
g.db.commit()
|
||||
return {"message": "Admin actions reverted!"}
|
||||
|
||||
@app.post("/@<username>/club_allow")
|
||||
|
@ -868,7 +875,6 @@ def ban_post(post_id, v):
|
|||
post.is_approved = 0
|
||||
post.stickied = None
|
||||
post.is_pinned = False
|
||||
post.removed_by = v.id
|
||||
post.ban_reason = v.username
|
||||
g.db.add(post)
|
||||
|
||||
|
@ -997,7 +1003,6 @@ def api_ban_comment(c_id, v):
|
|||
|
||||
comment.is_banned = True
|
||||
comment.is_approved = 0
|
||||
comment.removed_by = v.id
|
||||
comment.ban_reason = v.username
|
||||
g.db.add(comment)
|
||||
ma=ModAction(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue