diff --git a/docker-compose.yml b/docker-compose.yml index 6c3be8c67..28788954e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,6 +22,7 @@ services: - HCAPTCHA_SECRET=3435tdfsdudebussylmaoxxt43 - YOUTUBE_KEY=3435tdfsdudebussylmaoxxt43 - PUSHER_KEY=3435tdfsdudebussylmaoxxt43 + - CATBOX_KEY=3435tdfsdudebussylmaoxxt43 - SPAM_SIMILARITY_THRESHOLD=0.5 - SPAM_SIMILAR_COUNT_THRESHOLD=5 - SPAM_URL_SIMILARITY_THRESHOLD=0.1 diff --git a/env b/env index 3409332b5..6c02241c2 100644 --- a/env +++ b/env @@ -11,6 +11,7 @@ export DISCORD_BOT_TOKEN="3435tdfsdudebussylmaoxxt43" export HCAPTCHA_SECRET="3435tdfsdudebussylmaoxxt43" export YOUTUBE_KEY="3435tdfsdudebussylmaoxxt43" export PUSHER_KEY="3435tdfsdudebussylmaoxxt43" +export CATBOX_KEY="3435tdfsdudebussylmaoxxt43" export SPAM_SIMILARITY_THRESHOLD="0.5" export SPAM_SIMILAR_COUNT_THRESHOLD="5" export SPAM_URL_SIMILARITY_THRESHOLD="0.1" diff --git a/files/routes/posts.py b/files/routes/posts.py index f61c09af2..3d20f6521 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -20,8 +20,8 @@ from files.__main__ import app, limiter, cache, db_session from PIL import Image as PILimage from .front import frontlist, changeloglist - site = environ.get("DOMAIN").strip() +CATBOX_KEY = environ.get("CATBOX_KEY").strip() with open("snappy.txt", "r") as f: snappyquotes = f.read().split("{[para]}") @@ -809,13 +809,9 @@ def submit_post(v): g.db.refresh(new_post) - # check for uploaded image if request.files.get('file') and request.headers.get("cf-ipcountry") != "T1": file = request.files['file'] - #if not file.content_type.startswith('image/'): - # if request.headers.get("Authorization"): return {"error": f"Image files only"}, 400 - # else: return render_template("submit.html", v=v, error=f"Image files only.", title=title, body=request.values.get("body", "")), 400 if not file.content_type.startswith(('image/', 'video/')): if request.headers.get("Authorization"): return {"error": f"File type not allowed"}, 400 @@ -840,10 +836,10 @@ def submit_post(v): file.save(name) new_post.url = process_image(name) - # elif file.content_type.startswith('video/'): - # file.save("video.mp4") - # with open("video.mp4", 'rb') as f: - # new_post.url = requests.post('https://catbox.moe/user/api.php', data={'userhash':CATBOX_KEY, 'reqtype':'fileupload'}, files={'fileToUpload':f}).text + elif file.content_type.startswith('video/'): + file.save("video.mp4") + with open("video.mp4", 'rb') as f: + new_post.url = requests.post('https://catbox.moe/user/api.php', data={'userhash':CATBOX_KEY, 'reqtype':'fileupload'}, files={'fileToUpload':f}).text g.db.add(new_post) diff --git a/files/templates/submit.html b/files/templates/submit.html index c8e01a847..1fde8f2a0 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -73,7 +73,7 @@
-
+
Optional if you have text. - + You can upload videos up to 1 minute long.