fix 500 errors
parent
fea0ce115f
commit
96f4f8499f
|
@ -21,7 +21,7 @@ def process_files():
|
||||||
if file.content_type.startswith('image/'):
|
if file.content_type.startswith('image/'):
|
||||||
name = f'/images/{time.time()}'.replace('.','') + '.webp'
|
name = f'/images/{time.time()}'.replace('.','') + '.webp'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
url = process_image(name)
|
url = process_image(name, patron=g.v.patron)
|
||||||
body += f"\n\n![]({url})"
|
body += f"\n\n![]({url})"
|
||||||
elif file.content_type.startswith('video/'):
|
elif file.content_type.startswith('video/'):
|
||||||
body += f"\n\n{process_video(file)}"
|
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
|
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)
|
os.remove(filename)
|
||||||
abort(413)
|
abort(413)
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ def comment(v):
|
||||||
if file.content_type.startswith('image/'):
|
if file.content_type.startswith('image/'):
|
||||||
oldname = f'/images/{time.time()}'.replace('.','') + '.webp'
|
oldname = f'/images/{time.time()}'.replace('.','') + '.webp'
|
||||||
file.save(oldname)
|
file.save(oldname)
|
||||||
image = process_image(oldname)
|
image = process_image(oldname, patron=v.patron)
|
||||||
if image == "": return {"error":"Image upload failed"}, 400
|
if image == "": return {"error":"Image upload failed"}, 400
|
||||||
if v.admin_level > 2 and level == 1:
|
if v.admin_level > 2 and level == 1:
|
||||||
if parent_post.id == SIDEBAR_THREAD:
|
if parent_post.id == SIDEBAR_THREAD:
|
||||||
|
|
|
@ -949,7 +949,7 @@ def submit_post(v, sub=None):
|
||||||
if file.content_type.startswith('image/'):
|
if file.content_type.startswith('image/'):
|
||||||
name = f'/images/{time.time()}'.replace('.','') + '.webp'
|
name = f'/images/{time.time()}'.replace('.','') + '.webp'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
post.url = process_image(name)
|
post.url = process_image(name, patron=v.patron)
|
||||||
|
|
||||||
name2 = name.replace('.webp', 'r.webp')
|
name2 = name.replace('.webp', 'r.webp')
|
||||||
copyfile(name, name2)
|
copyfile(name, name2)
|
||||||
|
|
|
@ -518,7 +518,7 @@ def settings_images_profile(v):
|
||||||
|
|
||||||
name = f'/images/{time.time()}'.replace('.','') + '.webp'
|
name = f'/images/{time.time()}'.replace('.','') + '.webp'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
highres = process_image(name)
|
highres = process_image(name, patron=v.patron)
|
||||||
|
|
||||||
if not highres: abort(400)
|
if not highres: abort(400)
|
||||||
|
|
||||||
|
@ -556,7 +556,7 @@ def settings_images_banner(v):
|
||||||
|
|
||||||
name = f'/images/{time.time()}'.replace('.','') + '.webp'
|
name = f'/images/{time.time()}'.replace('.','') + '.webp'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
bannerurl = process_image(name)
|
bannerurl = process_image(name, patron=v.patron)
|
||||||
|
|
||||||
if bannerurl:
|
if bannerurl:
|
||||||
if v.bannerurl and '/images/' in v.bannerurl:
|
if v.bannerurl and '/images/' in v.bannerurl:
|
||||||
|
|
|
@ -486,7 +486,7 @@ def sub_banner(v, sub):
|
||||||
|
|
||||||
name = f'/images/{time.time()}'.replace('.','') + '.webp'
|
name = f'/images/{time.time()}'.replace('.','') + '.webp'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
bannerurl = process_image(name)
|
bannerurl = process_image(name, patron=v.patron)
|
||||||
|
|
||||||
if bannerurl:
|
if bannerurl:
|
||||||
if sub.bannerurl and '/images/' in sub.bannerurl:
|
if sub.bannerurl and '/images/' in sub.bannerurl:
|
||||||
|
@ -518,7 +518,7 @@ def sub_sidebar(v, sub):
|
||||||
file = request.files["sidebar"]
|
file = request.files["sidebar"]
|
||||||
name = f'/images/{time.time()}'.replace('.','') + '.webp'
|
name = f'/images/{time.time()}'.replace('.','') + '.webp'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
sidebarurl = process_image(name)
|
sidebarurl = process_image(name, patron=v.patron)
|
||||||
|
|
||||||
if sidebarurl:
|
if sidebarurl:
|
||||||
if sub.sidebarurl and '/images/' in sub.sidebarurl:
|
if sub.sidebarurl and '/images/' in sub.sidebarurl:
|
||||||
|
@ -550,7 +550,7 @@ def sub_marsey(v, sub):
|
||||||
file = request.files["marsey"]
|
file = request.files["marsey"]
|
||||||
name = f'/images/{time.time()}'.replace('.','') + '.webp'
|
name = f'/images/{time.time()}'.replace('.','') + '.webp'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
marseyurl = process_image(name)
|
marseyurl = process_image(name, patron=v.patron)
|
||||||
|
|
||||||
if marseyurl:
|
if marseyurl:
|
||||||
if sub.marseyurl and '/images/' in sub.marseyurl:
|
if sub.marseyurl and '/images/' in sub.marseyurl:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
CREATE TABLE public.media (
|
CREATE TABLE public.media (
|
||||||
kind character varying(5) NOT NULL,
|
kind character varying(5) NOT NULL,
|
||||||
filename character varying(23) NOT NULL,
|
filename character varying(55) NOT NULL,
|
||||||
user_id Integer NOT NULL,
|
user_id Integer NOT NULL,
|
||||||
created_utc integer NOT NULL,
|
created_utc integer NOT NULL,
|
||||||
size integer NOT NULL
|
size integer NOT NULL
|
||||||
|
|
Loading…
Reference in New Issue