From 72405e77f30ed7306c60c6b7a77c8f2fe5216283 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 18 Dec 2021 06:48:10 +0200 Subject: [PATCH] fdsfds --- files/routes/comments.py | 7 ++++--- files/routes/posts.py | 9 ++++----- files/routes/settings.py | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index 3819571eb..f6866813f 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -196,14 +196,14 @@ def api_comment(v): name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) url = process_image(name) + body += f"\n\n![]({url})" elif file.content_type.startswith('video/'): file.save("video.mp4") with open("video.mp4", 'rb') as f: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {CATBOX_KEY}'}, files=[('video', f)]).json()['data']['link'] + body += f"\n\n{url}" else: return {"error": f"Image/Video files only"}, 400 - body += f"\n\n{url}" - if v.agendaposter and not v.marseyawarded: for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) body = body.replace('I ', f'@{v.username} ') @@ -730,13 +730,14 @@ def edit_comment(cid, v): name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) url = process_image(name) + body += f"\n\n![]({url})" elif file.content_type.startswith('video/'): file.save("video.mp4") with open("video.mp4", 'rb') as f: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {CATBOX_KEY}'}, files=[('video', f)]).json()['data']['link'] + body += f"\n\n{url}" else: return {"error": f"Image/Video files only"}, 400 - body += f"\n\n{url}" body_md = CustomRenderer().render(mistletoe.Document(body)) body_html = sanitize(body_md) diff --git a/files/routes/posts.py b/files/routes/posts.py index 7b89b10d0..0bc905704 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -425,14 +425,14 @@ def edit_post(pid, v): name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) url = process_image(name) + body += f"\n\n![]({url})" elif file.content_type.startswith('video/'): file.save("video.mp4") with open("video.mp4", 'rb') as f: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {CATBOX_KEY}'}, files=[('video', f)]).json()['data']['link'] + body += f"\n\n{url}" else: return {"error": f"Image/Video files only"}, 400 - body += f"\n\n{url}" - if body != p.body: for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE): if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})') @@ -924,17 +924,16 @@ def submit_post(v): if file.content_type.startswith('image/'): name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) - url = process_image(name) + body += f"\n\n![]({url})" elif file.content_type.startswith('video/'): file.save("video.mp4") with open("video.mp4", 'rb') as f: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {CATBOX_KEY}'}, files=[('video', f)]).json()['data']['link'] + body += f"\n\n{url}" else: if request.headers.get("Authorization"): return {"error": f"Image/Video files only"}, 400 else: return render_template("submit.html", v=v, error=f"Image/Video files only."), 400 - body += f"\n\n{url}" - body_html = sanitize(CustomRenderer().render(mistletoe.Document(body))) if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 400 diff --git a/files/routes/settings.py b/files/routes/settings.py index a3270acb2..f57adcbaa 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -275,15 +275,15 @@ def settings_profile_post(v): name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) url = process_image(name) + bio += f"\n\n![]({url})" elif file.content_type.startswith('video/'): file.save("video.mp4") with open("video.mp4", 'rb') as f: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {CATBOX_KEY}'}, files=[('video', f)]).json()['data']['link'] + bio += f"\n\n{url}" else: if request.headers.get("Authorization"): return {"error": f"Image/Video files only"}, 400 else: return render_template("settings_profile.html", v=v, error=f"Image/Video files only."), 400 - - bio += f"\n\n{url}" bio_html = CustomRenderer().render(mistletoe.Document(bio)) bio_html = sanitize(bio_html)