From 245654a5a704a9c8897c333f0c272f0379754154 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 6 Jan 2022 16:20:45 +0200 Subject: [PATCH] fdfd --- files/routes/comments.py | 6 ++++-- files/routes/posts.py | 9 ++++++--- files/routes/settings.py | 8 ++------ files/templates/authforms.html | 2 +- files/templates/default.html | 2 +- files/templates/log.html | 2 +- files/templates/settings.html | 2 +- files/templates/settings2.html | 2 +- files/templates/submit.html | 2 +- 9 files changed, 18 insertions(+), 17 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index e974311c9..45d9f0483 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -202,7 +202,8 @@ def api_comment(v): 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 {IMGUR_KEY}'}, files=[('video', f)]).json()['data']['link'] + try: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)]).json()['data']['link'] + except: return {"error": "Imgur error"}, 400 body += f"\n\n{url}" else: return {"error": f"Image/Video files only"}, 400 @@ -701,7 +702,8 @@ def edit_comment(cid, v): 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 {IMGUR_KEY}'}, files=[('video', f)]).json()['data']['link'] + try: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)]).json()['data']['link'] + except: return {"error": "Imgur error"}, 400 body += f"\n\n{url}" else: return {"error": f"Image/Video files only"}, 400 diff --git a/files/routes/posts.py b/files/routes/posts.py index 8f6875a8b..067633a63 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -450,7 +450,8 @@ def edit_post(pid, v): 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 {IMGUR_KEY}'}, files=[('video', f)]).json()['data']['link'] + try: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)]).json()['data']['link'] + except: return {"error": "Imgur error"}, 400 body += f"\n\n{url}" else: return {"error": f"Image/Video files only"}, 400 @@ -939,7 +940,8 @@ def submit_post(v): 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 {IMGUR_KEY}'}, files=[('video', f)]).json()['data']['link'] + try: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)]).json()['data']['link'] + except: return {"error": "Imgur error"}, 400 body += f"\n\n{url}" else: if request.headers.get("Authorization"): return {"error": f"Image/Video files only"}, 400 @@ -1034,7 +1036,8 @@ def submit_post(v): 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 {IMGUR_KEY}'}, files=[('video', f)]).json()['data']['link'] + try: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)]).json()['data']['link'] + except: return {"error": "Imgur error"}, 400 new_post.url = url else: if request.headers.get("Authorization"): return {"error": f"File type not allowed"}, 400 diff --git a/files/routes/settings.py b/files/routes/settings.py index 409315ac2..8ee0c5db6 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -301,7 +301,8 @@ def settings_profile_post(v): 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 {IMGUR_KEY}'}, files=[('video', f)]).json()['data']['link'] + try: url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)]).json()['data']['link'] + except: return {"error": "Imgur error"}, 400 bio += f"\n\n{url}" else: if request.headers.get("Authorization"): return {"error": f"Image/Video files only"}, 400 @@ -607,11 +608,6 @@ def settings_security_post(v): if new_email == v.email: return render_template("settings_security.html", v=v, error="That email is already yours!") - existing = g.db.query(User.id).filter(User.id != v.id, - func.lower(User.email) == new_email.lower()).one_or_none() - if existing: - return render_template("settings_security.html", v=v, error="That email address is already in use.") - url = f"https://{app.config['SERVER_NAME']}/activate" now = int(time.time()) diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 7d3d085be..35f4cc116 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -15,7 +15,7 @@ {% if v %} - + {% if v.agendaposter %} - + {% if v.agendaposter %} - + {% if v.agendaposter %} - + {% if v.agendaposter %} - + {% else %} diff --git a/files/templates/submit.html b/files/templates/submit.html index ea6c017f0..0b22c0ec9 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -26,7 +26,7 @@ {% block stylesheets %} {% if v %} - + {% if v.agendaposter %}