master
Aevann1 2022-05-02 00:28:51 +02:00
parent a4b0565b5a
commit 94e6eb1ef6
3 changed files with 21 additions and 21 deletions

View File

@ -36,8 +36,8 @@ def get_logged_in_user():
abort(403)
if v and v.patron:
if request.content_length > 16 * 1024 * 1024: abort(413)
elif request.content_length > 8 * 1024 * 1024: abort(413)
if request.content_length and request.content_length > 16 * 1024 * 1024: abort(413)
elif request.content_length and request.content_length > 8 * 1024 * 1024: abort(413)
return v

View File

@ -890,14 +890,14 @@ def submit_post(v, sub=None):
title_html = filter_emojis_only(title, graceful=True)
if v.marseyawarded and not marseyaward_title_regex.fullmatch(title_html):
return {"error":"You can only type marseys!"}, 403
return error("You can only type marseys!")
if len(title_html) > 1500: return error("Rendered title is too big!")
if v.longpost and (len(body) < 280 or ' [](' in body or body.startswith('[](')):
return {"error":"You have to type more than 280 characters!"}, 403
return error("You have to type more than 280 characters!")
elif v.bird and len(body) > 140:
return {"error":"You have to type less than 140 characters!"}, 403
return error("You have to type less than 140 characters!")
embed = None
@ -1078,12 +1078,12 @@ def submit_post(v, sub=None):
file.save("video.mp4")
with open("video.mp4", 'rb') as f:
try: req = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)], timeout=5).json()['data']
except requests.Timeout: return {"error": "Video upload timed out, please try again!"}
except requests.Timeout: return error("Video upload timed out, please try again!")
try: url = req['link']
except:
error = req['error']
if error == 'File exceeds max duration': error += ' (60 seconds)'
return {"error": error}, 400
err = req['error']
if err == 'File exceeds max duration': err += ' (60 seconds)'
return error(err)
if url.endswith('.'): url += 'mp4'
body += f"\n\n{url}"
else:
@ -1092,7 +1092,7 @@ def submit_post(v, sub=None):
body_html = sanitize(body)
if v.marseyawarded and marseyaward_body_regex.search(body_html):
return {"error":"You can only type marseys!"}, 403
return error("You can only type marseys!")
if len(body_html) > 40000: return error("Submission body_html too long! (max 40k characters)")
@ -1187,12 +1187,12 @@ def submit_post(v, sub=None):
file.save("video.mp4")
with open("video.mp4", 'rb') as f:
try: req = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {IMGUR_KEY}'}, files=[('video', f)], timeout=5).json()['data']
except requests.Timeout: return {"error": "Video upload timed out, please try again!"}
except requests.Timeout: return error("Video upload timed out, please try again!")
try: url = req['link']
except:
error = req['error']
if error == 'File exceeds max duration': error += ' (60 seconds)'
return {"error": error}, 400
err = req['error']
if err == 'File exceeds max duration': err += ' (60 seconds)'
return error(err)
if url.endswith('.'): url += 'mp4'
post.url = url
else:

View File

@ -68,8 +68,8 @@ Text 2
</tr>
<tr>
<td>Images</td>
<td>https://i.imgur.com/Lf6dfPO.jpg</td>
<td><img loading="lazy" alt="example image" referrerpolicy="no-referrer" src="https://i.imgur.com/Lf6dfPO.jpg"></td>
<td>https://i.imgur.com/SwVuagI_d.webp</td>
<td><img loading="lazy" alt="example image" referrerpolicy="no-referrer" src="https://i.imgur.com/SwVuagI_d.webp"></td>
</tr>
<tr>
<td>Youtube Videos</td>
@ -94,12 +94,12 @@ Text 2
<tr>
<td>Large Emojis</td>
<td>:#marseylove:</td>
<td><img loading="lazy" data-bs-toggle="tooltip" class="emoji-lg" alt=":!marseylove:" title=":!marseylove:" src="/e/marseylove.webp"></td>
<td><img loading="lazy" data-bs-toggle="tooltip" b alt=":marseylove:" title=":marseylove:" src="/e/marseylove.webp"></td>
</tr>
<tr>
<td>Large Mirrored Emojis</td>
<td>:#!marseylove:</td>
<td><img loading="lazy" data-bs-toggle="tooltip" class="emoji-lg mirrored" alt=":!marseylove:" title=":!marseylove:" src="/e/marseylove.webp"></td>
<td><img loading="lazy" data-bs-toggle="tooltip" b alt=":!marseylove:" title=":!marseylove:" src="/e/marseylove.webp"></td>
</tr>
<tr>
<td>Random Marsey</td>
@ -173,7 +173,7 @@ Text 2
<tr>
<td>Spoilers</td>
<td>||bussy > gussy||</td>
<td><p class="spoiler">bussy > gussy</p></td>
<td><p><spoiler>bussy &gt; gussy</spoiler></p></td>
</tr>
<tr>
<td>Username Mention</td>
@ -182,8 +182,8 @@ Text 2
</tr>
<tr>
<td>Subreddit Mention</td>
<td>r/{{SITE_NAME}}</td>
<td><a class="d-inline-block" rel="nofollow noopener noreferrer" href="https://www.reddit.com/r/{{SITE_NAME}}/">r/{{SITE_NAME}}</a></td>
<td>r/drama</td>
<td><a class="d-inline-block" rel="nofollow noopener noreferrer" href="https://www.reddit.com/r/drama/">r/drama</a></td>
</tr>
<tr>
<td>Redditor Mention</td>