forked from rDrama/rDrama
1
0
Fork 0
master
Aevann1 2021-07-31 07:33:32 +02:00
parent ed2a9f40e6
commit f794c6b18e
4 changed files with 9 additions and 27 deletions

View File

@ -3,7 +3,7 @@ from drama.helpers.wrappers import *
from drama.helpers.alerts import * from drama.helpers.alerts import *
from drama.helpers.get import * from drama.helpers.get import *
from drama.classes.award import * from drama.classes.award import *
from flask import g, jsonify, request from flask import g, request
def banaward_trigger(post=None, comment=None): def banaward_trigger(post=None, comment=None):

View File

@ -249,8 +249,7 @@ def api_comment(v):
return {"error": f"You already made that comment: {existing.permalink}"}, 409 return {"error": f"You already made that comment: {existing.permalink}"}, 409
if parent.author.any_block_exists(v) and not v.admin_level>=3: if parent.author.any_block_exists(v) and not v.admin_level>=3:
return jsonify( return {"error": "You can't reply to users who have blocked you, or users you have blocked."}, 403
{"error": "You can't reply to users who have blocked you, or users you have blocked."}), 403
# get bot status # get bot status
is_bot = request.headers.get("X-User-Type","")=="Bot" is_bot = request.headers.get("X-User-Type","")=="Bot"

View File

@ -314,19 +314,9 @@ def changelog(v):
# check if ids exist # check if ids exist
posts = get_posts(ids, v=v) posts = get_posts(ids, v=v)
return {'html': lambda: render_template("changelog.html", if request.headers.get("Authorization"): return {"data": [x.json for x in posts], "next_exists": next_exists}
v=v, else: return render_template("changelog.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page)
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
}
)
}
@app.get("/random") @app.get("/random")
@auth_desired @auth_desired

View File

@ -41,8 +41,7 @@ def oauth_authorize_prompt(v):
scopes = scopes_txt.split(',') scopes = scopes_txt.split(',')
if not scopes: if not scopes:
return jsonify( return {"oauth_error": "One or more scopes must be specified as a comma-separated list."}, 400
{"oauth_error": "One or more scopes must be specified as a comma-separated list."}), 400
for scope in scopes: for scope in scopes:
if scope not in SCOPES: if scope not in SCOPES:
@ -103,8 +102,7 @@ def oauth_authorize_post(v):
scopes = scopes_txt.split(',') scopes = scopes_txt.split(',')
if not scopes: if not scopes:
return jsonify( return {"oauth_error": "One or more scopes must be specified as a comma-separated list"}, 400
{"oauth_error": "One or more scopes must be specified as a comma-separated list"}), 400
for scope in scopes: for scope in scopes:
if scope not in SCOPES: if scope not in SCOPES:
@ -149,8 +147,7 @@ def oauth_grant():
client_id=request.values.get("client_id"), client_id=request.values.get("client_id"),
client_secret=request.values.get("client_secret")).first() client_secret=request.values.get("client_secret")).first()
if not application: if not application:
return jsonify( return {"oauth_error": "Invalid `client_id` or `client_secret`"}, 401
{"oauth_error": "Invalid `client_id` or `client_secret`"}), 401
if application.is_banned: if application.is_banned:
return {"oauth_error": f"Application `{application.app_name}` is suspended."}, 403 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) g.db.add(a)
return jsonify({"message": "Tokens Rerolled", return {"message": "Tokens Rerolled", "id": a.client_id, "secret": a.client_secret}
"id": a.client_id,
"secret": a.client_secret
}
)
@app.post("/oauth/rescind/<aid>") @app.post("/oauth/rescind/<aid>")