fix 500 errors

remotes/1693176582716663532/tmp_refs/heads/watchparty
Aevann1 2022-10-06 09:30:38 +02:00
parent fea0ce115f
commit 96f4f8499f
6 changed files with 11 additions and 11 deletions

View File

@ -21,7 +21,7 @@ def process_files():
if file.content_type.startswith('image/'):
name = f'/images/{time.time()}'.replace('.','') + '.webp'
file.save(name)
url = process_image(name)
url = process_image(name, patron=g.v.patron)
body += f"\n\n![]({url})"
elif file.content_type.startswith('video/'):
body += f"\n\n{process_video(file)}"
@ -112,10 +112,10 @@ def process_video(file):
def process_image(filename=None, resize=0, trim=False):
def process_image(filename=None, resize=0, trim=False, patron=False):
size = os.stat(filename).st_size
if size > 16 * 1024 * 1024 or not g.v.patron and size > 8 * 1024 * 1024:
if size > 16 * 1024 * 1024 or not patron and size > 8 * 1024 * 1024:
os.remove(filename)
abort(413)

View File

@ -194,7 +194,7 @@ def comment(v):
if file.content_type.startswith('image/'):
oldname = f'/images/{time.time()}'.replace('.','') + '.webp'
file.save(oldname)
image = process_image(oldname)
image = process_image(oldname, patron=v.patron)
if image == "": return {"error":"Image upload failed"}, 400
if v.admin_level > 2 and level == 1:
if parent_post.id == SIDEBAR_THREAD:

View File

@ -949,7 +949,7 @@ def submit_post(v, sub=None):
if file.content_type.startswith('image/'):
name = f'/images/{time.time()}'.replace('.','') + '.webp'
file.save(name)
post.url = process_image(name)
post.url = process_image(name, patron=v.patron)
name2 = name.replace('.webp', 'r.webp')
copyfile(name, name2)

View File

@ -518,7 +518,7 @@ def settings_images_profile(v):
name = f'/images/{time.time()}'.replace('.','') + '.webp'
file.save(name)
highres = process_image(name)
highres = process_image(name, patron=v.patron)
if not highres: abort(400)
@ -556,7 +556,7 @@ def settings_images_banner(v):
name = f'/images/{time.time()}'.replace('.','') + '.webp'
file.save(name)
bannerurl = process_image(name)
bannerurl = process_image(name, patron=v.patron)
if bannerurl:
if v.bannerurl and '/images/' in v.bannerurl:

View File

@ -486,7 +486,7 @@ def sub_banner(v, sub):
name = f'/images/{time.time()}'.replace('.','') + '.webp'
file.save(name)
bannerurl = process_image(name)
bannerurl = process_image(name, patron=v.patron)
if bannerurl:
if sub.bannerurl and '/images/' in sub.bannerurl:
@ -518,7 +518,7 @@ def sub_sidebar(v, sub):
file = request.files["sidebar"]
name = f'/images/{time.time()}'.replace('.','') + '.webp'
file.save(name)
sidebarurl = process_image(name)
sidebarurl = process_image(name, patron=v.patron)
if sidebarurl:
if sub.sidebarurl and '/images/' in sub.sidebarurl:
@ -550,7 +550,7 @@ def sub_marsey(v, sub):
file = request.files["marsey"]
name = f'/images/{time.time()}'.replace('.','') + '.webp'
file.save(name)
marseyurl = process_image(name)
marseyurl = process_image(name, patron=v.patron)
if marseyurl:
if sub.marseyurl and '/images/' in sub.marseyurl:

View File

@ -1,6 +1,6 @@
CREATE TABLE public.media (
kind character varying(5) NOT NULL,
filename character varying(23) NOT NULL,
filename character varying(55) NOT NULL,
user_id Integer NOT NULL,
created_utc integer NOT NULL,
size integer NOT NULL