Aevann1 2022-07-29 02:43:22 +02:00
parent b06524a895
commit f920371f3a
1 changed files with 2 additions and 4 deletions

View File

@ -23,10 +23,6 @@ def api_flag_post(pid, v):
reason = reason[:100] reason = reason[:100]
if not reason.startswith('!'):
existing = g.db.query(Flag.post_id).filter_by(user_id=v.id, post_id=post.id).one_or_none()
if existing: return "", 409
reason = filter_emojis_only(reason) reason = filter_emojis_only(reason)
if len(reason) > 350: return {"error": "Too long."} if len(reason) > 350: return {"error": "Too long."}
@ -67,6 +63,8 @@ def api_flag_post(pid, v):
return {"message": f"Post moved to /h/{post.sub}"} return {"message": f"Post moved to /h/{post.sub}"}
else: else:
existing = g.db.query(Flag.post_id).filter_by(user_id=v.id, post_id=post.id).one_or_none()
if existing: return "", 409
flag = Flag(post_id=post.id, user_id=v.id, reason=reason) flag = Flag(post_id=post.id, user_id=v.id, reason=reason)
g.db.add(flag) g.db.add(flag)