From 9e6b2b4eb41c924aa2fda52641119173f13e28b0 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 11 Nov 2021 21:14:11 +0200 Subject: [PATCH] image size for patrons --- files/__main__.py | 2 +- files/routes/comments.py | 8 ++++++-- files/routes/posts.py | 4 +++- files/routes/settings.py | 12 +++++++++--- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/files/__main__.py b/files/__main__.py index a900cb925..2cd233d96 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -34,7 +34,7 @@ app.config["SERVER_NAME"] = environ.get("DOMAIN").strip() app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 86400 app.config["SESSION_COOKIE_NAME"] = "session_" + environ.get("SITE_NAME").strip().lower() app.config["VERSION"] = "1.0.0" -app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 +app.config['MAX_CONTENT_LENGTH'] = 8 * 1024 * 1024 app.config["SESSION_COOKIE_SECURE"] = bool(int(environ.get("FORCE_HTTPS", 1))) app.config["SESSION_COOKIE_SAMESITE"] = "Lax" app.config["PERMANENT_SESSION_LIFETIME"] = 60 * 60 * 24 * 365 diff --git a/files/routes/comments.py b/files/routes/comments.py index c6d27a139..92e98e1f3 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -133,7 +133,9 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): @is_not_banned @validate_formkey def api_comment(v): - if request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413 + if v and v.patron: + if request.content_length > 8 * 1024 * 1024: return "Max file size is 8 MB.", 413 + elif request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413 parent_submission = request.values.get("submission").strip() parent_fullname = request.values.get("parent_fullname").strip() @@ -589,7 +591,9 @@ def api_comment(v): @auth_required @validate_formkey def edit_comment(cid, v): - if request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413 + if v and v.patron: + if request.content_length > 8 * 1024 * 1024: return "Max file size is 8 MB.", 413 + elif request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413 c = get_comment(cid, v=v) diff --git a/files/routes/posts.py b/files/routes/posts.py index 2fec0f55e..723b4b1d5 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -506,7 +506,9 @@ def thumbnail_thread(pid): @is_not_banned @validate_formkey def submit_post(v): - if request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413 + if v and v.patron: + if request.content_length > 8 * 1024 * 1024: return "Max file size is 8 MB.", 413 + elif request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413 title = request.values.get("title", "").strip() url = request.values.get("url", "").strip() diff --git a/files/routes/settings.py b/files/routes/settings.py index 140b461da..2a1b841d4 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -45,7 +45,9 @@ def removebackground(v): @auth_required @validate_formkey def settings_profile_post(v): - if request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413 + if v and v.patron: + if request.content_length > 8 * 1024 * 1024: return "Max file size is 8 MB.", 413 + elif request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413 updated = False @@ -677,7 +679,9 @@ def settings_log_out_others(v): @auth_required @validate_formkey def settings_images_profile(v): - if request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413 + if v and v.patron: + if request.content_length > 8 * 1024 * 1024: return "Max file size is 8 MB.", 413 + elif request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413 if request.headers.get("cf-ipcountry") == "T1": return "Image uploads are not allowed through TOR.", 403 @@ -711,7 +715,9 @@ def settings_images_profile(v): @auth_required @validate_formkey def settings_images_banner(v): - if request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413 + if v and v.patron: + if request.content_length > 8 * 1024 * 1024: return "Max file size is 8 MB.", 413 + elif request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413 if request.headers.get("cf-ipcountry") == "T1": return "Image uploads are not allowed through TOR.", 403