mirror of
https://github.com/bsedin/matrix-webhook.git
synced 2026-04-09 11:25:40 +00:00
allow "key" to be passed as a parameter
This was initially designed and implemented in #4 Co-authored-by: Sven Seeberg <mail@sven-seeberg.de>
This commit is contained in:
@@ -38,10 +38,14 @@ async def handler(request):
|
||||
except json.decoder.JSONDecodeError:
|
||||
return create_json_response(HTTPStatus.BAD_REQUEST, "Invalid JSON")
|
||||
|
||||
# legacy naming:
|
||||
# legacy naming
|
||||
if "text" in data and "body" not in data:
|
||||
data["body"] = data["text"]
|
||||
|
||||
# allow key to be passed as a parameter
|
||||
if "key" in request.rel_url.query and "key" not in data:
|
||||
data["key"] = request.rel_url.query["key"]
|
||||
|
||||
if not all(key in data for key in ["body", "key"]):
|
||||
return create_json_response(
|
||||
HTTPStatus.BAD_REQUEST, "Missing body and/or API key property"
|
||||
|
||||
Reference in New Issue
Block a user