add 409 to errors

* also move check for AUTOJANNY_ID to before has_blocked
remotes/1693176582716663532/tmp_refs/heads/watchparty
justcool393 2022-10-11 07:51:14 -07:00
parent c0acb1722b
commit 39e49a508f
3 changed files with 11 additions and 17 deletions

View File

@ -16,6 +16,7 @@ WERKZEUG_ERROR_DESCRIPTIONS = {
404: "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.",
405: "The method is not allowed for the requested URL.",
406: "The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.",
409: "A conflict happened while processing the request. The resource might have been modified while the request was being processed.",
413: "The data value transmitted exceeds the capacity limit.",
414: "The length of the requested URL exceeds the capacity limit for this server. The request cannot be processed.",
415: "The server does not support the media type transmitted in the request.",
@ -32,6 +33,7 @@ ERROR_TITLES = {
404: "Not Found",
405: "Method Not Allowed",
406: "Too Many Pings",
409: "Conflict",
413: "Max image/audio size is 8 MB (16 MB for paypigs)",
414: "Max video size is 32 MB (64 MB for paypigs)",
415: "Unsupported Media Type",
@ -48,6 +50,7 @@ ERROR_MSGS = {
404: "Someone typed something wrong and it was probably you, please do better.",
405: "idk how anyone gets this error but if you see this, remember to follow @carpathianflorist<BR>the original error text here talked about internet gremlins and wtf",
406: "Max limit is 5 for comments and 50 for posts",
409: "There's a conflict between what you're trying to do and what you or someone else has done and because of that you can't do what you're trying to do, sorry not sorry",
413: "Max image/audio size is 8 MB (16 MB for paypigs)",
414: "Max video size is 32 MB (64 MB for paypigs)",
415: "Please upload only Image, Video, or Audio files!",
@ -68,6 +71,7 @@ ERROR_MARSEYS = {
404: "marseyconfused",
405: "marseyretard",
406: "marseyrage",
409: "marseynoyou",
413: "marseyretard",
414: "marseychonker2",
415: "marseydetective",
@ -81,6 +85,7 @@ ERROR_MARSEYS = {
@app.errorhandler(404)
@app.errorhandler(405)
@app.errorhandler(406)
@app.errorhandler(409)
@app.errorhandler(413)
@app.errorhandler(414)
@app.errorhandler(415)

View File

@ -102,8 +102,7 @@ def flag_post(pid, v):
return {"message": f"Post moved to /h/{post.sub}"}
else:
existing = g.db.query(Flag.post_id).filter_by(user_id=v.id, post_id=post.id).one_or_none()
if existing:
return {"error": "You already reported this post!"}, 409
if existing: abort(409, "You already reported this post!")
flag = Flag(post_id=post.id, user_id=v.id, reason=reason)
g.db.add(flag)
@ -120,8 +119,7 @@ def 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 {"error": "You already reported this comment!"}, 409
if existing: abort(409, "You already reported this comment!")
reason = request.values.get("reason", "").strip()

View File

@ -630,14 +630,9 @@ def settings_block_user(v):
send_notification(user.id, f"@{v.username} has tried to block you and failed because of your unblockable status!")
abort(403, "This user is unblockable.")
if user.id == v.id:
return {"error": "You can't block yourself."}, 409
if v.has_blocked(user):
return {"error": f"You have already blocked @{user.username}."}, 409
if user.id == AUTOJANNY_ID:
return {"error": "You can't block this user."}, 409
if user.id == v.id: abort(400, "You can't block yourself")
if user.id == AUTOJANNY_ID: abort(403, "You can't block this user")
if v.has_blocked(user): abort(409, f"You have already blocked @{user.username}")
new_block = UserBlock(user_id=v.id,
target_id=user.id,
@ -658,13 +653,9 @@ def settings_block_user(v):
@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{SITE}-{session.get("lo_user")}')
@auth_required
def settings_unblock_user(v):
user = get_user(request.values.get("username"))
x = v.has_blocked(user)
if not x: abort(409)
if not x: abort(409, "You can't unblock someone you haven't blocked")
g.db.delete(x)
if not v.shadowbanned and user.admin_level >= PERMS['USER_BLOCKS_VISIBLE']: