From 616e15ebb95f745c26e543f9dfa3265a11809ed3 Mon Sep 17 00:00:00 2001 From: TLSM Date: Sat, 15 Oct 2022 10:11:14 -0400 Subject: [PATCH] Fix posting/commenting from API. The rework to v.client meant that `is_bot` on Submission and Comment would attempt to be populated with a ClientAuth object when submitted by a bot other than Snappy or bbbb. SQLAlchemy requires an actual boolean, not just a truthy value. --- files/routes/comments.py | 4 +++- files/routes/posts.py | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index 0efbd291f..4465b82ee 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -255,7 +255,9 @@ def comment(v): 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.id != BBBB_ID and v.client or (SITE == 'pcmemes.net' and v.id == SNAPPY_ID) + is_bot = (v.client is not None + and v.id != BBBB_ID + or (SITE == 'pcmemes.net' and v.id == SNAPPY_ID)) execute_antispam_comment_check(body, v) diff --git a/files/routes/posts.py b/files/routes/posts.py index 15db20131..2f3fdadf0 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -877,8 +877,6 @@ def submit_post(v, sub=None): if embed and len(embed) > 1500: embed = None - is_bot = v.id != BBBB_ID and v.client or (SITE == 'pcmemes.net' and v.id == SNAPPY_ID) - if request.values.get("ghost") and v.coins >= 100: v.charge_account('coins', 100) ghost = True @@ -894,7 +892,7 @@ def submit_post(v, sub=None): over_18=bool(request.values.get("over_18","")), new=bool(request.values.get("new","")), app_id=v.client.application.id if v.client else None, - is_bot = is_bot, + is_bot=(v.client is not None), url=url, body=body, body_html=body_html,