add clearer error messages
parent
c3d0b2c60a
commit
32ca7d1a69
|
@ -326,15 +326,15 @@ def get_comments_v_properties(v, should_keep_func=None, *criterion):
|
|||
def get_hole(hole, v=None, graceful=False):
|
||||
if not hole:
|
||||
if graceful: return None
|
||||
else: abort(404)
|
||||
else: abort(404, f"/h/{hole} was not found.")
|
||||
hole = hole.replace('/h/', '').replace('h/', '').strip().lower()
|
||||
if not hole:
|
||||
if graceful: return None
|
||||
else: abort(404)
|
||||
else: abort(404, f"/h/{hole} was not found.")
|
||||
hole = g.db.get(Hole, hole)
|
||||
if not hole:
|
||||
if graceful: return None
|
||||
else: abort(404)
|
||||
else: abort(404, f"/h/{hole} was not found.")
|
||||
return hole
|
||||
|
||||
@cache.memoize(timeout=3600)
|
||||
|
|
|
@ -92,7 +92,7 @@ def process_audio(file, v, old=None):
|
|||
extension = guess_extension(file.content_type)
|
||||
if not extension:
|
||||
os.remove(old)
|
||||
abort(400)
|
||||
abort(400, "Unsupported audio format.")
|
||||
new = old + extension
|
||||
|
||||
try:
|
||||
|
@ -101,7 +101,7 @@ def process_audio(file, v, old=None):
|
|||
os.remove(old)
|
||||
if os.path.isfile(new):
|
||||
os.remove(new)
|
||||
abort(400)
|
||||
abort(400, "Something went wrong processing your audio on our end. Please try uploading it to https://pomf2.lain.la and post the link instead.")
|
||||
|
||||
os.remove(old)
|
||||
|
||||
|
@ -162,7 +162,7 @@ def process_video(file, v):
|
|||
bitrate = int(video_info.get('bit_rate', 3000000))
|
||||
except:
|
||||
os.remove(old)
|
||||
abort(400, "Something went wrong processing your video and it might be on our end. Please try uploading it to https://pomf2.lain.la and post the link instead.")
|
||||
abort(400, "Something went wrong processing your video on our end. Please try uploading it to https://pomf2.lain.la and post the link instead.")
|
||||
|
||||
if codec != 'h264':
|
||||
copyfile(old, new)
|
||||
|
@ -177,7 +177,7 @@ def process_video(file, v):
|
|||
os.remove(old)
|
||||
if os.path.isfile(new):
|
||||
os.remove(new)
|
||||
abort(400)
|
||||
abort(400, "Something went wrong processing your video on our end. Please try uploading it to https://pomf2.lain.la and post the link instead.")
|
||||
|
||||
os.remove(old)
|
||||
|
||||
|
@ -227,7 +227,7 @@ def process_image(filename, v, resize=0, trim=False, uploader_id=None):
|
|||
except:
|
||||
os.remove(filename)
|
||||
if has_request and not filename.startswith('/chat_images/'):
|
||||
abort(415)
|
||||
abort(400, "Something went wrong processing your image on our end. Please try uploading it to https://pomf2.lain.la and post the link instead.")
|
||||
return None
|
||||
|
||||
params.append(filename)
|
||||
|
|
|
@ -742,8 +742,7 @@ def normalize_url(url):
|
|||
if not url.startswith('/') and not url.startswith('https://rdrama.net') and not url.startswith('https://watchpeopledie.tv'):
|
||||
try: parsed_url = urlparse(url)
|
||||
except:
|
||||
print(url, flush=True)
|
||||
abort(500)
|
||||
abort(400, f"Something is wrong with the url you submitted ({url}) and it couldn't be parsed.")
|
||||
|
||||
netloc = parsed_url.netloc
|
||||
path = parsed_url.path
|
||||
|
|
|
@ -135,7 +135,7 @@ def remove_admin(v, username):
|
|||
user = get_user(username)
|
||||
|
||||
if user.admin_level > v.admin_level:
|
||||
abort(403)
|
||||
abort(403, "You can't remove an admin with higher level than you.")
|
||||
|
||||
if user.admin_level:
|
||||
user.admin_level = 0
|
||||
|
@ -164,7 +164,8 @@ def distribute(v, kind, option_id):
|
|||
|
||||
option = g.db.get(cls, option_id)
|
||||
|
||||
if option.exclusive != 2: abort(403)
|
||||
if option.exclusive != 2:
|
||||
abort(400, "This is not a bet.")
|
||||
|
||||
option.exclusive = 3
|
||||
g.db.add(option)
|
||||
|
@ -226,7 +227,7 @@ def revert_actions(v, username):
|
|||
revertee = get_user(username)
|
||||
|
||||
if revertee.admin_level > v.admin_level:
|
||||
abort(403)
|
||||
abort(403, "You can't revert the actions of an admin with higher level that you.")
|
||||
|
||||
ma = ModAction(
|
||||
kind="revert",
|
||||
|
@ -485,7 +486,7 @@ def badge_grant_post(v):
|
|||
user = get_user(username)
|
||||
|
||||
try: badge_id = int(request.values.get("badge_id"))
|
||||
except: abort(400)
|
||||
except: abort(400, "Invalid badge id.")
|
||||
|
||||
if badge_id not in [b.id for b in badges]:
|
||||
abort(403, "You can't grant this badge!")
|
||||
|
@ -497,7 +498,7 @@ def badge_grant_post(v):
|
|||
abort(400, "This badge requires a url!")
|
||||
|
||||
if url:
|
||||
if '\\' in url: abort(400)
|
||||
if '\\' in url: abort(400, "Nice try nigger.")
|
||||
if url.startswith(f'{SITE_FULL}/'):
|
||||
url = url.split(SITE_FULL, 1)[1]
|
||||
else:
|
||||
|
@ -563,10 +564,10 @@ def badge_remove_post(v):
|
|||
user = get_user(username)
|
||||
|
||||
try: badge_id = int(request.values.get("badge_id"))
|
||||
except: abort(400)
|
||||
except: abort(400, "Invalid badge id.")
|
||||
|
||||
if badge_id not in [b.id for b in badges]:
|
||||
abort(403)
|
||||
abort(403, "You're not allowed to remove this badge.")
|
||||
|
||||
badge = user.has_badge(badge_id)
|
||||
if not badge: continue
|
||||
|
@ -749,7 +750,7 @@ def admin_delink_relink_alt(v, username, other):
|
|||
user2 = get_account(other)
|
||||
ids = [user1.id, user2.id]
|
||||
a = g.db.query(Alt).filter(Alt.user1.in_(ids), Alt.user2.in_(ids)).one_or_none()
|
||||
if not a: abort(404)
|
||||
if not a: abort(404, "Alt doesn't exist.")
|
||||
g.db.delete(a)
|
||||
|
||||
cache.delete_memoized(get_alt_graph_ids, user1.id)
|
||||
|
@ -869,7 +870,7 @@ def unchud(fullname, v):
|
|||
def shadowban(user_id, v):
|
||||
user = get_account(user_id)
|
||||
if user.admin_level > v.admin_level:
|
||||
abort(403)
|
||||
abort(403, "You can't shadowban an admin with higher level than you.")
|
||||
user.shadowbanned = v.id
|
||||
reason = request.values.get("reason", "").strip()
|
||||
|
||||
|
@ -1000,7 +1001,7 @@ def ban_user(fullname, v):
|
|||
user = get_account(fullname)
|
||||
|
||||
if user.admin_level > v.admin_level:
|
||||
abort(403)
|
||||
abort(403, "You can't ban an admin with higher level than you.")
|
||||
|
||||
if user.is_permabanned:
|
||||
abort(403, f"@{user.username} is already banned permanently!")
|
||||
|
|
Loading…
Reference in New Issue