This commit is contained in:
Aevann1 2021-10-03 23:51:39 +02:00
parent e28c59ba4a
commit eefbd43e0f
4 changed files with 22 additions and 18 deletions

View file

@ -263,9 +263,9 @@ def api_comment(v):
file=request.files["file"]
if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.webp'
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.gif'
file.save(name)
url = process_image(name)
url = request.host_url[:-1] + process_image(name)
body = request.values.get("body") + f"\n![]({url})"
body = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body)
@ -684,9 +684,9 @@ def edit_comment(cid, v):
file=request.files["file"]
if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.webp'
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.gif'
file.save(name)
url = process_image(name)
url = request.host_url[:-1] + process_image(name)
body += f"\n![]({url})"
body_md = CustomRenderer().render(mistletoe.Document(body))