Switch over comment reporting to use the new system
This commit is contained in:
parent
a0488f2b23
commit
bd5fd8fb21
4 changed files with 37 additions and 51 deletions
|
@ -559,16 +559,20 @@ def reported_comments(v):
|
|||
is_approved=None,
|
||||
is_banned=False
|
||||
).join(Comment.reports).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
comments_just_ids = g.db.query(Comment) \
|
||||
.filter(Comment.filter_state == 'reported') \
|
||||
.order_by(Comment.id.desc()) \
|
||||
.offset(25 * (page - 1)) \
|
||||
.limit(26) \
|
||||
.with_entities(Comment.id)
|
||||
|
||||
listing = [c.id for c in listing]
|
||||
next_exists = len(listing) > 25
|
||||
listing = listing[:25]
|
||||
|
||||
listing = get_comments(listing, v=v)
|
||||
comment_ids = [c.id for c in comments_just_ids]
|
||||
next_exists = len(comment_ids) > 25
|
||||
comments = get_comments(comment_ids[:25], v=v)
|
||||
|
||||
return render_template("admin/reported_comments.html",
|
||||
next_exists=next_exists,
|
||||
listing=listing,
|
||||
listing=comments,
|
||||
page=page,
|
||||
v=v,
|
||||
standalone=True)
|
||||
|
|
|
@ -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!"}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue