From e5f54243ea7d1b01390c649e53fe53bef55b3c1f Mon Sep 17 00:00:00 2001 From: justcool393 Date: Fri, 25 Nov 2022 16:12:25 -0600 Subject: [PATCH] polls: constantify max poll options --- files/helpers/const.py | 1 + files/routes/comments.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index 43cc3c0a1..134f2b7ea 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -436,6 +436,7 @@ MODMAIL_ID = 2 POLL_THREAD = 0 POLL_BET_COINS = 200 +POLL_MAX_OPTIONS = 10 WELCOME_MSG = f"Welcome to {SITE_NAME}!" LOTTERY_TICKET_COST = 12 diff --git a/files/routes/comments.py b/files/routes/comments.py index 7c71fc6b6..e6766f93b 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -132,12 +132,12 @@ def comment(v): abort(403, "You can't reply to users who have blocked you or users that you have blocked.") options = [] - for i in list(poll_regex.finditer(body))[:10]: + for i in list(poll_regex.finditer(body))[:POLL_MAX_OPTIONS]: options.append(i.group(1)) body = body.replace(i.group(0), "") choices = [] - for i in list(choice_regex.finditer(body))[:10]: + for i in list(choice_regex.finditer(body))[:POLL_MAX_OPTIONS]: choices.append(i.group(1)) body = body.replace(i.group(0), "") @@ -390,7 +390,7 @@ def edit_comment(cid, v): elif v.bird and len(body) > 140: abort(403, "You have to type less than 140 characters!") - for i in list(poll_regex.finditer(body))[:10]: + for i in list(poll_regex.finditer(body))[:POLL_MAX_OPTIONS]: body = body.replace(i.group(0), "") body_html = filter_emojis_only(i.group(1)) if len(body_html) > 500: abort(400, "Poll option too long!") @@ -401,7 +401,7 @@ def edit_comment(cid, v): ) g.db.add(option) - for i in list(choice_regex.finditer(body))[:10]: + for i in list(choice_regex.finditer(body))[:POLL_MAX_OPTIONS]: body = body.replace(i.group(0), "") body_html = filter_emojis_only(i.group(1)) if len(body_html) > 500: abort(400, "Poll option too long!")