Switch over comment reporting to use the new system

This commit is contained in:
Julian Rota 2022-07-03 18:31:04 -04:00 committed by Ben Rog-Wilhelm
parent a0488f2b23
commit bd5fd8fb21
4 changed files with 37 additions and 51 deletions

View file

@ -42,49 +42,14 @@ def api_flag_post(pid, v):
def api_flag_comment(cid, v):
comment = get_comment(cid)
existing = g.db.query(CommentFlag.comment_id).filter_by( user_id=v.id, comment_id=comment.id).one_or_none()
if existing: return "", 409
reason = request.values.get("reason", "").strip()
if blackjack and any(i in reason.lower() for i in blackjack.split()):
v.shadowbanned = 'AutoJanny'
send_repeatable_notification(CARP_ID, f"reports on {comment.permalink}")
reason = reason[:100]
reason = request.values.get("reason", "").strip()[:100]
reason = filter_emojis_only(reason)
if len(reason) > 350: return {"error": "Too long."}
flag = CommentFlag(comment_id=comment.id, user_id=v.id, reason=reason)
g.db.add(flag)
g.db.query(Comment) \
.where(Comment.id == comment.id, Comment.filter_state != 'ignored') \
.update({Comment.filter_state: 'reported'})
g.db.commit()
return {"message": "Comment reported!"}
@app.post('/del_report/comment/<cid>/<uid>')
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@admin_level_required(2)
def remove_report_comment(v, cid, uid):
cid = int(cid)
uid = int(uid)
report = g.db.query(CommentFlag).filter_by(comment_id=cid, user_id=uid).one()
g.db.delete(report)
ma=ModAction(
kind="delete_report",
user_id=v.id,
target_comment_id=cid
)
g.db.add(ma)
g.db.commit()
return {"message": "Report removed successfully!"}