From 01b508ae919f93c7ed8e40e9783f4fcf7bf681a3 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 25 Feb 2024 01:19:37 +0200 Subject: [PATCH] a final solution to the @jannies question --- files/routes/comments.py | 3 +++ files/routes/posts.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/files/routes/comments.py b/files/routes/comments.py index 8330c2cbd7..35b426f43c 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -167,6 +167,7 @@ def comment(v): if len(body) > COMMENT_BODY_LENGTH_LIMIT: abort(400, f'Comment body is too long (max {COMMENT_BODY_LENGTH_LIMIT} characters)') + body = body.replace('@jannies', '!jannies') if not posting_to_post or post_target.id not in ADMIGGER_THREADS: if v.longpost and (len(body) < 280 or ' [](' in body or body.startswith('[](')): @@ -606,6 +607,8 @@ def edit_comment(cid, v): if len(body) < 1 and not (request.files.get("file") and not g.is_tor): abort(400, "You have to actually type something!") + body = body.replace('@jannies', '!jannies') + if body != c.body or request.files.get("file") and not g.is_tor: if c.author.longpost and (len(body) < 280 or ' [](' in body or body.startswith('[](')): abort(403, "You have to type more than 280 characters!") diff --git a/files/routes/posts.py b/files/routes/posts.py index 925aa63fd0..b809dce4e9 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -471,6 +471,8 @@ def submit_post(v, hole=None): 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)') + body = body.replace('@jannies', '!jannies') + if not title: abort(400, "Please enter a better title!") @@ -1040,6 +1042,8 @@ def edit_post(pid, v): 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)') + body = body.replace('@jannies', '!jannies') + if p.author.longpost and (len(body) < 280 or ' [](' in body or body.startswith('[](')): abort(403, "You have to type more than 280 characters!") elif p.author.bird and len(body) > 140: