From 3f9913fc7f3adb97722438e87a3c0fa18a109220 Mon Sep 17 00:00:00 2001 From: Aevann Date: Tue, 10 Oct 2023 22:34:38 +0300 Subject: [PATCH] stop using 204 --- files/assets/js/core.js | 3 ++- files/routes/errors.py | 2 +- files/routes/static.py | 2 +- files/routes/users.py | 4 ++-- files/routes/votes.py | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/files/assets/js/core.js b/files/assets/js/core.js index a673e50e6..00506ab5f 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -310,10 +310,11 @@ function sendFormXHR(form, extraActionsOnSuccess) { t.classList.remove("disabled"); } - if (xhr.status != 204) { + try { const data = JSON.parse(xhr.response); showToast(success, getMessageFromJsonData(success, data)); } + catch {} if (success && extraActionsOnSuccess) extraActionsOnSuccess(xhr); }; diff --git a/files/routes/errors.py b/files/routes/errors.py index 212d112a5..a6ec6cf89 100644 --- a/files/routes/errors.py +++ b/files/routes/errors.py @@ -67,4 +67,4 @@ def error_500(e): def allow_nsfw(): session["nsfw_cookies"] = int(time.time()) + 3600 redir = request.values.get("redir", "/") - return '', 204 + return '' diff --git a/files/routes/static.py b/files/routes/static.py index ea9f163ad..6d00decbf 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -389,7 +389,7 @@ def mobile_app(v): @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) def dismiss_mobile_tip(): session["tooltip_dismissed"] = int(time.time()) - return "", 204 + return "" @app.get("/transfers/") @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) diff --git a/files/routes/users.py b/files/routes/users.py index 0aa56f164..a84f38cc0 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -1281,7 +1281,7 @@ def subscribed_posts(v, username): @auth_required def fp(v, fp): if session.get("GLOBAL"): - return '', 204 + return '' v.fp = fp users = g.db.query(User).filter(User.fp == fp, User.id != v.id).all() @@ -1298,7 +1298,7 @@ def fp(v, fp): check_for_alts(v, include_current_session=True) g.db.add(v) - return '', 204 + return '' @app.post("/toggle_pins//") @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) diff --git a/files/routes/votes.py b/files/routes/votes.py index bc4e69e88..fac0f184d 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -66,7 +66,7 @@ def vote_post_comment(target_id, new, v, cls, vote_cls): imlazy = 0 - if existing and existing.vote_type == new: return "", 204 + if existing and existing.vote_type == new: return "" if existing: if existing.vote_type == 0 and new != 0: imlazy = 1 @@ -182,7 +182,7 @@ def vote_post_comment(target_id, new, v, cls, vote_cls): target.author.pay_account('coins', coin_value) target.author.truescore += coin_delta - return "", 204 + return "" @app.get("/votes/") @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)