From 1a30d6ccade3b2184011374def70e3513b6a8e4c Mon Sep 17 00:00:00 2001 From: justcool393 Date: Sun, 6 Nov 2022 23:24:09 -0600 Subject: [PATCH] blocks: don't check for blocks on the route midway through creating a post blocks: short circuit with admin check (can avoid a query in some cases) --- files/routes/comments.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index 67077e672..7eb99d5a4 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -130,6 +130,9 @@ def comment(v): abort(403, "You have to type less than 140 characters!") if not body and not request.files.get('file'): abort(400, "You need to actually write something!") + + if v.admin_level < PERMS['POST_COMMENT_MODERATION'] and parent.author.any_block_exists(v): + abort(403, "You can't reply to users who have blocked you or users that you have blocked.") options = [] for i in poll_regex.finditer(body): @@ -212,9 +215,6 @@ def comment(v): ).first() if existing: abort(409, f"You already made that comment: /comment/{existing.id}") - if parent.author.any_block_exists(v) and v.admin_level < PERMS['POST_COMMENT_MODERATION']: - abort(403, "You can't reply to users who have blocked you or users that you have blocked.") - is_bot = (v.client is not None and v.id not in PRIVILEGED_USER_BOTS or (SITE == 'pcmemes.net' and v.id == SNAPPY_ID))