diff --git a/drama/routes/awards.py b/drama/routes/awards.py index a0defc34c5..73ebd2f5ca 100644 --- a/drama/routes/awards.py +++ b/drama/routes/awards.py @@ -3,7 +3,7 @@ from drama.helpers.wrappers import * from drama.helpers.alerts import * from drama.helpers.get import * from drama.classes.award import * -from flask import g, jsonify, request +from flask import g, request def banaward_trigger(post=None, comment=None): diff --git a/drama/routes/comments.py b/drama/routes/comments.py index 4ebb2aeabf..83bf2d3fdd 100644 --- a/drama/routes/comments.py +++ b/drama/routes/comments.py @@ -249,8 +249,7 @@ def api_comment(v): return {"error": f"You already made that comment: {existing.permalink}"}, 409 if parent.author.any_block_exists(v) and not v.admin_level>=3: - return jsonify( - {"error": "You can't reply to users who have blocked you, or users you have blocked."}), 403 + return {"error": "You can't reply to users who have blocked you, or users you have blocked."}, 403 # get bot status is_bot = request.headers.get("X-User-Type","")=="Bot" diff --git a/drama/routes/front.py b/drama/routes/front.py index c264549f22..affa2ad55e 100644 --- a/drama/routes/front.py +++ b/drama/routes/front.py @@ -314,19 +314,9 @@ def changelog(v): # check if ids exist posts = get_posts(ids, v=v) - return {'html': lambda: render_template("changelog.html", - v=v, - listing=posts, - next_exists=next_exists, - sort=sort, - t=t, - page=page, - ), - 'api': lambda: jsonify({"data": [x.json for x in posts], - "next_exists": next_exists - } - ) - } + if request.headers.get("Authorization"): return {"data": [x.json for x in posts], "next_exists": next_exists} + else: return render_template("changelog.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page) + @app.get("/random") @auth_desired diff --git a/drama/routes/oauth.py b/drama/routes/oauth.py index 716790cf72..e988e7226e 100644 --- a/drama/routes/oauth.py +++ b/drama/routes/oauth.py @@ -41,8 +41,7 @@ def oauth_authorize_prompt(v): scopes = scopes_txt.split(',') if not scopes: - return jsonify( - {"oauth_error": "One or more scopes must be specified as a comma-separated list."}), 400 + return {"oauth_error": "One or more scopes must be specified as a comma-separated list."}, 400 for scope in scopes: if scope not in SCOPES: @@ -103,8 +102,7 @@ def oauth_authorize_post(v): scopes = scopes_txt.split(',') if not scopes: - return jsonify( - {"oauth_error": "One or more scopes must be specified as a comma-separated list"}), 400 + return {"oauth_error": "One or more scopes must be specified as a comma-separated list"}, 400 for scope in scopes: if scope not in SCOPES: @@ -149,8 +147,7 @@ def oauth_grant(): client_id=request.values.get("client_id"), client_secret=request.values.get("client_secret")).first() if not application: - return jsonify( - {"oauth_error": "Invalid `client_id` or `client_secret`"}), 401 + return {"oauth_error": "Invalid `client_id` or `client_secret`"}, 401 if application.is_banned: return {"oauth_error": f"Application `{application.app_name}` is suspended."}, 403 @@ -419,11 +416,7 @@ def reroll_oauth_tokens(aid, v): g.db.add(a) - return jsonify({"message": "Tokens Rerolled", - "id": a.client_id, - "secret": a.client_secret - } - ) + return {"message": "Tokens Rerolled", "id": a.client_id, "secret": a.client_secret} @app.post("/oauth/rescind/")