Filter out reports from permabanned users.

This commit is contained in:
Ben Rog-Wilhelm 2023-05-29 06:25:35 -05:00
parent 143eb36aaa
commit e9ca6e3239

View file

@ -27,9 +27,12 @@ def api_flag_post(pid, v):
else:
flag = Flag(post_id=post.id, user_id=v.id, reason=reason)
g.db.add(flag)
g.db.query(Submission) \
.where(Submission.id == post.id, Submission.filter_state != 'ignored') \
.update({Submission.filter_state: 'reported'})
# We only want to notify if the user is not permabanned
if not v.is_suspended_permanently:
g.db.query(Submission) \
.where(Submission.id == post.id, Submission.filter_state != 'ignored') \
.update({Submission.filter_state: 'reported'})
g.db.commit()
@ -46,9 +49,13 @@ def api_flag_comment(cid, v):
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'})
# We only want to notify if the user is not permabanned
if not v.is_suspended_permanently:
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!"}