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)
remotes/1693176582716663532/tmp_refs/heads/watchparty
justcool393 2022-11-06 23:24:09 -06:00
parent 1adb6bf5f8
commit 1a30d6ccad
1 changed files with 3 additions and 3 deletions

View File

@ -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))