consistency in error messages
parent
1fa0e3e8d2
commit
7c6dc4c7b4
|
@ -604,7 +604,7 @@ def process_options(v, target):
|
|||
body = i.group(2)
|
||||
|
||||
if len(body) > 500:
|
||||
abort(400, f"Poll option body too long! (Max 500 characters)")
|
||||
abort(400, f"Poll option body is too long (Max 500 characters)")
|
||||
|
||||
if isinstance(target, Post):
|
||||
cls = PostOption
|
||||
|
|
|
@ -9,10 +9,10 @@ def badge_grant(user, badge_id, description=None, url=None, notify=True):
|
|||
if existing: return
|
||||
|
||||
if description and len(description) > 256:
|
||||
abort(400, "Custom description is too long, max 256 characters!")
|
||||
abort(400, "Custom description is too long (max 256 characters)")
|
||||
|
||||
if url and len(url) > 256:
|
||||
abort(400, "URL is too long, max 256 characters!")
|
||||
abort(400, "URL is too long (max 256 characters)")
|
||||
|
||||
badge = Badge(
|
||||
badge_id=int(badge_id),
|
||||
|
|
|
@ -882,7 +882,7 @@ def shadowban(user_id, v):
|
|||
reason = filter_emojis_only(reason)
|
||||
|
||||
if len(reason) > 256:
|
||||
abort(400, "Ban reason too long!")
|
||||
abort(400, "Ban reason is too long (max 256 characters)")
|
||||
|
||||
user.shadowban_reason = reason
|
||||
g.db.add(user)
|
||||
|
@ -1730,10 +1730,7 @@ def ban_domain(v):
|
|||
if not reason: abort(400, 'Reason is required!')
|
||||
|
||||
if len(reason) > 100:
|
||||
abort(400, 'Reason is too long (max 100 characters)!')
|
||||
|
||||
if len(reason) > 100:
|
||||
abort(400, 'Reason is too long!')
|
||||
abort(400, 'Reason is too long (max 100 characters)')
|
||||
|
||||
existing = g.db.get(BannedDomain, domain)
|
||||
if not existing:
|
||||
|
|
|
@ -258,7 +258,7 @@ atexit.register(close_running_threads)
|
|||
def messagereply(v):
|
||||
body = request.values.get("body", "").strip()
|
||||
if len(body) > COMMENT_BODY_LENGTH_LIMIT:
|
||||
abort(400, f'Message is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)!')
|
||||
abort(400, f'Message is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)')
|
||||
|
||||
id = request.values.get("parent_id")
|
||||
parent = get_comment(id, v=v)
|
||||
|
@ -292,14 +292,14 @@ def messagereply(v):
|
|||
if not g.is_tor and get_setting("dm_media"):
|
||||
body = process_files(request.files, v, body, is_dm=True, dm_user=user)
|
||||
if len(body) > COMMENT_BODY_LENGTH_LIMIT:
|
||||
abort(400, f'Message is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)!')
|
||||
abort(400, f'Message is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)')
|
||||
|
||||
if not body: abort(400, "Message is empty!")
|
||||
|
||||
body_html = sanitize(body)
|
||||
|
||||
if len(body_html) > COMMENT_BODY_HTML_LENGTH_LIMIT:
|
||||
abort(400, "Rendered message too long!")
|
||||
abort(400, "Rendered message is too long!")
|
||||
|
||||
if parent.sentto == MODMAIL_ID:
|
||||
sentto = MODMAIL_ID
|
||||
|
|
|
@ -167,7 +167,7 @@ def comment(v):
|
|||
|
||||
body = request.values.get("body", "").strip()
|
||||
if len(body) > COMMENT_BODY_LENGTH_LIMIT:
|
||||
abort(400, f'Comment body is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)!')
|
||||
abort(400, f'Comment body is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)')
|
||||
|
||||
|
||||
if not posting_to_post or post_target.id not in ADMIGGER_THREADS:
|
||||
|
@ -218,7 +218,7 @@ def comment(v):
|
|||
name = badge_def["name"]
|
||||
|
||||
if len(name) > 50:
|
||||
abort(400, "Badge name is too long!")
|
||||
abort(400, "Badge name is too long (max 50 characters)")
|
||||
|
||||
if not badge_name_regex.fullmatch(name):
|
||||
abort(400, "Invalid badge name!")
|
||||
|
@ -246,7 +246,7 @@ def comment(v):
|
|||
|
||||
body = body.strip()
|
||||
if len(body) > COMMENT_BODY_LENGTH_LIMIT:
|
||||
abort(400, f'Comment body is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)!')
|
||||
abort(400, f'Comment body is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)')
|
||||
|
||||
if v.admin_level >= PERMS['USE_ADMIGGER_THREADS'] and posting_to_post and post_target.id == SNAPPY_THREAD and level == 1:
|
||||
with open(f"snappy_{SITE_NAME}.txt", "r+") as f:
|
||||
|
@ -298,7 +298,7 @@ def comment(v):
|
|||
abort(403, "You can only type marseys!")
|
||||
|
||||
if len(body_html) > COMMENT_BODY_HTML_LENGTH_LIMIT:
|
||||
abort(400, "Rendered comment too long!")
|
||||
abort(400, "Rendered comment is too long!")
|
||||
|
||||
c.body_html = body_html
|
||||
|
||||
|
@ -658,7 +658,7 @@ def edit_comment(cid, v):
|
|||
|
||||
body = request.values.get("body", "").strip()
|
||||
if len(body) > COMMENT_BODY_LENGTH_LIMIT:
|
||||
abort(400, f'Comment body is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)!')
|
||||
abort(400, f'Comment body is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)')
|
||||
|
||||
if len(body) < 1 and not (request.files.get("file") and not g.is_tor):
|
||||
abort(400, "You have to actually type something!")
|
||||
|
@ -673,12 +673,12 @@ def edit_comment(cid, v):
|
|||
|
||||
body = process_files(request.files, v, body)
|
||||
if len(body) > COMMENT_BODY_LENGTH_LIMIT:
|
||||
abort(400, f'Comment body is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)!')
|
||||
abort(400, f'Comment body is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)')
|
||||
|
||||
body_html = sanitize(body, golden=False, limit_pings=5, showmore=(not v.hieroglyphs), commenters_ping_post_id=c.parent_post, obj=c, author=c.author)
|
||||
|
||||
if len(body_html) > COMMENT_BODY_HTML_LENGTH_LIMIT:
|
||||
abort(400, "Rendered comment too long!")
|
||||
abort(400, "Rendered comment is too long!")
|
||||
|
||||
if c.author.hieroglyphs and marseyaward_body_regex.search(body_html):
|
||||
abort(403, "You can only type marseys!")
|
||||
|
|
|
@ -992,7 +992,7 @@ def post_hole_snappy_quotes(v, hole):
|
|||
if v.shadowbanned: abort(400)
|
||||
|
||||
if len(snappy_quotes) > HOLE_SNAPPY_QUOTES_LENGTH:
|
||||
abort(400, f"Hole Snappy Quotes are too long (max {HOLE_SNAPPY_QUOTES_LENGTH} characters)")
|
||||
abort(400, f"Quotes are too long (max {HOLE_SNAPPY_QUOTES_LENGTH} characters)")
|
||||
|
||||
hole.snappy_quotes = snappy_quotes
|
||||
g.db.add(hole)
|
||||
|
|
|
@ -59,7 +59,7 @@ def rescind(v, aid):
|
|||
def request_api_keys(v):
|
||||
description = request.values.get("description", "").strip()
|
||||
if len(description) > 256:
|
||||
abort(400, 'App description is too long (max 256 characters)!')
|
||||
abort(400, 'App description is too long (max 256 characters)')
|
||||
|
||||
new_app = OauthApp(
|
||||
app_name=request.values.get('name').replace('<','').replace('>',''),
|
||||
|
@ -122,7 +122,7 @@ def edit_oauth_app(v, aid):
|
|||
|
||||
description = request.values.get("description", "").strip()
|
||||
if len(description) > 256:
|
||||
abort(400, 'App description is too long (max 256 characters)!')
|
||||
abort(400, 'App description is too long (max 256 characters)')
|
||||
|
||||
app.description = description
|
||||
|
||||
|
|
|
@ -463,11 +463,11 @@ def submit_post(v, hole=None):
|
|||
|
||||
title = request.values.get("title", "").strip()
|
||||
if len(title) > POST_TITLE_LENGTH_LIMIT:
|
||||
abort(400, f'Post title is too long (max {POST_TITLE_LENGTH_LIMIT} characters)!')
|
||||
abort(400, f'Post title is too long (max {POST_TITLE_LENGTH_LIMIT} characters)')
|
||||
|
||||
body = request.values.get("body", "").strip()
|
||||
if len(body) > POST_BODY_LENGTH_LIMIT(g.v):
|
||||
abort(400, f'Post body is too long (max {POST_BODY_LENGTH_LIMIT(g.v)} characters)!')
|
||||
abort(400, f'Post body is too long (max {POST_BODY_LENGTH_LIMIT(g.v)} characters)')
|
||||
|
||||
if not title:
|
||||
abort(400, "Please enter a better title!")
|
||||
|
@ -555,7 +555,7 @@ def submit_post(v, hole=None):
|
|||
|
||||
body = process_files(request.files, v, body).strip()
|
||||
if len(body) > POST_BODY_LENGTH_LIMIT(g.v):
|
||||
abort(400, f'Post body is too long (max {POST_BODY_LENGTH_LIMIT(g.v)} characters)!')
|
||||
abort(400, f'Post body is too long (max {POST_BODY_LENGTH_LIMIT(g.v)} characters)')
|
||||
|
||||
flag_notify = (request.values.get("notify", "on") == "on")
|
||||
flag_new = request.values.get("new", False, bool) or 'megathread' in title.lower()
|
||||
|
@ -611,7 +611,7 @@ def submit_post(v, hole=None):
|
|||
abort(400, "You can only type marseys!")
|
||||
|
||||
if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT:
|
||||
abort(400, "Post body_html too long!")
|
||||
abort(400, "Rendered post body is too long!")
|
||||
|
||||
p.body_html = body_html
|
||||
|
||||
|
@ -1016,11 +1016,11 @@ def edit_post(pid, v):
|
|||
|
||||
title = request.values.get("title", "").strip()
|
||||
if len(title) > POST_TITLE_LENGTH_LIMIT:
|
||||
abort(400, f'Post title is too long (max {POST_TITLE_LENGTH_LIMIT} characters)!')
|
||||
abort(400, f'Post title is too long (max {POST_TITLE_LENGTH_LIMIT} characters)')
|
||||
|
||||
body = request.values.get("body", "").strip()
|
||||
if len(body) > POST_BODY_LENGTH_LIMIT(g.v):
|
||||
abort(400, f'Post body is too long (max {POST_BODY_LENGTH_LIMIT(g.v)} characters)!')
|
||||
abort(400, f'Post body is too long (max {POST_BODY_LENGTH_LIMIT(g.v)} characters)')
|
||||
|
||||
if p.author.longpost and (len(body) < 280 or ' [](' in body or body.startswith('[](')):
|
||||
abort(403, "You have to type more than 280 characters!")
|
||||
|
@ -1056,7 +1056,7 @@ def edit_post(pid, v):
|
|||
|
||||
body = process_files(request.files, v, body).strip()
|
||||
if len(body) > POST_BODY_LENGTH_LIMIT(g.v):
|
||||
abort(400, f'Post body is too long (max {POST_BODY_LENGTH_LIMIT(g.v)} characters)!')
|
||||
abort(400, f'Post body is too long (max {POST_BODY_LENGTH_LIMIT(g.v)} characters)')
|
||||
|
||||
if body != p.body or p.chudded:
|
||||
body_html = sanitize(body, golden=False, limit_pings=100, obj=p, author=p.author)
|
||||
|
@ -1071,7 +1071,7 @@ def edit_post(pid, v):
|
|||
if execute_blackjack(v, p, text, 'post'): break
|
||||
|
||||
if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT:
|
||||
abort(400, "Post body_html too long!")
|
||||
abort(400, "Rendered post body is too long!")
|
||||
|
||||
p.body_html = body_html
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ def report_post(pid, v):
|
|||
og_flair = reason[1:]
|
||||
reason_html = filter_emojis_only(reason)
|
||||
if len(reason_html) > 350:
|
||||
abort(400, "Report reason too long!")
|
||||
abort(400, "Rendered report reason is too long!")
|
||||
|
||||
if reason.startswith('!') and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or post.hole and v.mods_hole(post.hole)):
|
||||
post.flair = reason_html[1:]
|
||||
|
@ -99,8 +99,8 @@ def report_comment(cid, v):
|
|||
abort(400, "Report reason is too long (max 100 characters)")
|
||||
|
||||
reason_html = filter_emojis_only(reason)
|
||||
|
||||
if len(reason_html) > 350: abort(400, "Too long!")
|
||||
if len(reason_html) > 350:
|
||||
abort(400, "Rendered report reason is too long!")
|
||||
|
||||
report = CommentReport(comment_id=comment.id, user_id=v.id, reason=reason_html)
|
||||
g.db.add(report)
|
||||
|
|
|
@ -254,7 +254,7 @@ def settings_personal_post(v):
|
|||
|
||||
sig_html = sanitize(sig, blackjack="signature")
|
||||
if len(sig_html) > 1000:
|
||||
abort(400, "Your sig is too long")
|
||||
abort(400, "Your rendered sig is too long!")
|
||||
|
||||
v.sig = sig
|
||||
v.sig_html = sig_html
|
||||
|
@ -264,11 +264,11 @@ def settings_personal_post(v):
|
|||
elif not updated and FEATURES['USERS_PROFILE_BODYTEXT'] and request.values.get("friends"):
|
||||
friends = request.values.get("friends", "").strip()
|
||||
if len(friends) > BIO_FRIENDS_ENEMIES_LENGTH_LIMIT:
|
||||
abort(400, f'Ypur friend list is too long (max {BIO_FRIENDS_ENEMIES_LENGTH_LIMIT} characters)!')
|
||||
abort(400, f'Ypur friend list is too long (max {BIO_FRIENDS_ENEMIES_LENGTH_LIMIT} characters)')
|
||||
|
||||
friends_html = sanitize(friends, blackjack="friends")
|
||||
if len(friends_html) > BIO_FRIENDS_ENEMIES_HTML_LENGTH_LIMIT:
|
||||
abort(400, "Your friend list is too long")
|
||||
abort(400, "Your rendered friend list is too long!")
|
||||
|
||||
notify_users = NOTIFY_USERS(friends, v, oldtext=v.friends)
|
||||
if notify_users:
|
||||
|
@ -297,11 +297,11 @@ def settings_personal_post(v):
|
|||
elif not updated and FEATURES['USERS_PROFILE_BODYTEXT'] and request.values.get("enemies"):
|
||||
enemies = request.values.get("enemies", "").strip()
|
||||
if len(enemies) > BIO_FRIENDS_ENEMIES_LENGTH_LIMIT:
|
||||
abort(400, f'You enemy list is too long (max {BIO_FRIENDS_ENEMIES_LENGTH_LIMIT} characters)!')
|
||||
abort(400, f'You enemy list is too long (max {BIO_FRIENDS_ENEMIES_LENGTH_LIMIT} characters)')
|
||||
|
||||
enemies_html = sanitize(enemies, blackjack="enemies")
|
||||
if len(enemies_html) > BIO_FRIENDS_ENEMIES_HTML_LENGTH_LIMIT:
|
||||
abort(400, "Your enemy list is too long")
|
||||
abort(400, "Your rendered enemy list is too long!")
|
||||
|
||||
notify_users = NOTIFY_USERS(enemies, v, oldtext=v.enemies)
|
||||
if notify_users:
|
||||
|
@ -331,11 +331,11 @@ def settings_personal_post(v):
|
|||
bio = request.values.get("bio", "").strip()
|
||||
bio = process_files(request.files, v, bio)
|
||||
if len(bio) > BIO_FRIENDS_ENEMIES_LENGTH_LIMIT:
|
||||
abort(400, f'Your bio is too long (max {BIO_FRIENDS_ENEMIES_LENGTH_LIMIT} characters)!')
|
||||
abort(400, f'Your bio is too long (max {BIO_FRIENDS_ENEMIES_LENGTH_LIMIT} characters)')
|
||||
|
||||
bio_html = sanitize(bio, blackjack="bio")
|
||||
if len(bio_html) > BIO_FRIENDS_ENEMIES_HTML_LENGTH_LIMIT:
|
||||
abort(400, "Your bio is too long")
|
||||
abort(400, "Your rendered bio is too long!")
|
||||
|
||||
v.bio_html=bio_html
|
||||
g.db.add(v)
|
||||
|
@ -961,7 +961,7 @@ def settings_change_flair(v):
|
|||
flair_html = censor_slurs_profanities(flair_html, None)
|
||||
|
||||
if len(flair_html) > 1000:
|
||||
abort(400, "Flair too long!")
|
||||
abort(400, "Your rendered flair is too long!")
|
||||
|
||||
execute_blackjack(v, None, flair, "flair")
|
||||
else:
|
||||
|
|
|
@ -135,7 +135,7 @@ def transfer_currency(v, username, currency_name, apply_tax):
|
|||
|
||||
if reason:
|
||||
if len(reason) > TRANSFER_MESSAGE_LENGTH_LIMIT:
|
||||
abort(400, f"Reason is too long, max {TRANSFER_MESSAGE_LENGTH_LIMIT} characters")
|
||||
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}"
|
||||
|
||||
|
@ -599,19 +599,19 @@ def message(v, username=None, id=None):
|
|||
|
||||
body = request.values.get("message", "").strip()
|
||||
if len(body) > COMMENT_BODY_LENGTH_LIMIT:
|
||||
abort(400, f'Message is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)!')
|
||||
abort(400, f'Message is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)')
|
||||
|
||||
if not g.is_tor and get_setting("dm_media"):
|
||||
body = process_files(request.files, v, body, is_dm=True, dm_user=user)
|
||||
if len(body) > COMMENT_BODY_LENGTH_LIMIT:
|
||||
abort(400, f'Message is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)!')
|
||||
abort(400, f'Message is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)')
|
||||
|
||||
if not body: abort(400, "Message is empty!")
|
||||
|
||||
body_html = sanitize(body)
|
||||
|
||||
if len(body_html) > COMMENT_BODY_HTML_LENGTH_LIMIT:
|
||||
abort(400, "Rendered message too long!")
|
||||
abort(400, "Rendered message is too long!")
|
||||
|
||||
existing = g.db.query(Comment.id).filter(
|
||||
Comment.author_id == v.id,
|
||||
|
|
Loading…
Reference in New Issue