better error messages

pull/83/head
Aevann 2022-12-28 11:50:48 +02:00
parent 53fcc2ac40
commit f7aa7d8dfd
4 changed files with 8 additions and 5 deletions

View File

@ -1534,7 +1534,7 @@ def admin_banned_domains(v):
# reason = filter_emojis_only(reason)
# if len(reason) > 100:
# abort(400, 'Reason is too long (max 100 characters)!')
# abort(400, 'Reason is too long!')
# existing = g.db.get(BannedDomain, domain)
# if not existing:

View File

@ -321,7 +321,7 @@ def edit_post(pid, v):
if not execute_blackjack(v, p, text, 'submission'): break
if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT:
abort(400, f"Submission body_html too long! (max {POST_BODY_HTML_LENGTH_LIMIT} characters)")
abort(400, f"Submission body_html too long!")
p.body_html = body_html
@ -688,7 +688,8 @@ def submit_post(v:User, sub=None):
if v.marseyawarded and marseyaward_body_regex.search(body_html):
return error("You can only type marseys!")
if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT: return error(f"Submission body_html too long! (max {POST_BODY_HTML_LENGTH_LIMIT} characters)")
if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT:
return error(f"Submission body_html too long!")
flag_notify = (request.values.get("notify", "on") == "on")
flag_new = request.values.get("new", False, bool) or 'megathread' in title.lower()

View File

@ -24,7 +24,8 @@ def flag_post(pid, v):
reason = reason[:100]
og_flair = reason[1:]
reason = filter_emojis_only(reason)
if len(reason) > 350: abort(400, "Too long.")
if len(reason) > 350:
abort(400, "Report reason too long!")
if reason.startswith('!') and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or post.sub and v.mods(post.sub)):
post.flair = reason[1:]

View File

@ -320,7 +320,8 @@ def transfer_currency(v:User, username:str, currency_name:Literal['coins', 'mars
notif_text = f":marseycapitalistmanlet: @{v.username} has gifted you {amount-tax} {currency_name}!"
if reason:
if len(reason) > TRANSFER_MESSAGE_LENGTH_LIMIT: abort(400, f"Reason is too long, max {TRANSFER_MESSAGE_LENGTH_LIMIT} characters")
if len(reason) > TRANSFER_MESSAGE_LENGTH_LIMIT:
abort(400, f"Reason is too long, max {TRANSFER_MESSAGE_LENGTH_LIMIT} characters")
notif_text += f"\n\n> {reason}"
log_message += f"\n\n> {reason}"