allow direct formatted_body

This was initially designed and implemented in #6

Co-authored-by: Gerhard Bräunlich <gerhard.braeunlich@id.ethz.ch>
This commit is contained in:
Guilhem Saurel 2021-07-31 12:03:26 +02:00
parent fa8f9b4a51
commit 3bebc88ee2
3 changed files with 34 additions and 1 deletions

View file

@ -54,12 +54,17 @@ async def handler(request):
if data["key"] != conf.API_KEY:
return create_json_response(HTTPStatus.UNAUTHORIZED, "Invalid API key")
if "formatted_body" in data:
formatted_body = data["formatted_body"]
else:
formatted_body = markdown(str(data["body"]), extensions=["extra"])
room_id = request.path[1:]
content = {
"msgtype": "m.text",
"body": data["body"],
"format": "org.matrix.custom.html",
"formatted_body": markdown(str(data["body"]), extensions=["extra"]),
"formatted_body": formatted_body,
}
for _ in range(10):
try: