reports - py

master
fireworks88 2021-08-25 14:15:53 +02:00
parent b9b2aabe40
commit 4a4e7f7b94
1 changed files with 22 additions and 1 deletions

View File

@ -59,4 +59,25 @@ def api_flag_comment(cid, v):
g.db.add(flag)
return "", 204
return "", 204
@app.delete('/report/<report_fn>')
@auth_required
@validate_formkey
def remove_report(report_fn, v):
if v.admin_level < 6:
return {"error": "go outside"}, 403
if report_fn.startswith('c'):
report = g.db.query(CommentFlag).filter_by(id=int(report_fn.lstrip('c'))).first()
elif report_fn.startswith('p'):
report = g.db.query(Flag).filter_by(id=int(report_fn.lstrip('p'))).first()
else:
return {"error": "Invalid report ID"}, 400
_response = f"Removed @{report.user.username}'s report"
g.db.delete(report)
return {"message": _response}, 200