diff --git a/files/classes/user.py b/files/classes/user.py index ececb839f..478d372ab 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -815,7 +815,7 @@ class User(Base): - def ban(self, admin=None, reason=None, days=0): + def ban(self, admin=None, reason=None, days=0.0): if days: self.unban_utc = int(time.time()) + (days * 86400) g.db.add(self) diff --git a/files/helpers/actions.py b/files/helpers/actions.py index ff98459c7..201984f6d 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -62,6 +62,7 @@ def execute_snappy(post, v): else: SNAPPY_CHOICES = SNAPPY_QUOTES elif SNAPPY_MARSEYS: SNAPPY_CHOICES = SNAPPY_MARSEYS elif SNAPPY_QUOTES: SNAPPY_CHOICES = SNAPPY_QUOTES + else: SNAPPY_CHOICES = [""] body = random.choice(SNAPPY_CHOICES).strip() if body.startswith('▼'): diff --git a/files/routes/admin.py b/files/routes/admin.py index 03faa40af..5d2b98b9c 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -993,7 +993,11 @@ def ban_user(user_id, v): if user.admin_level > v.admin_level: abort(403) - days = float(request.values.get("days")) if request.values.get('days') else 0 + days = 0.0 + try: + days = float(request.values.get("days")) + except: + pass reason = request.values.get("reason").strip()[:256] reason = filter_emojis_only(reason) @@ -1009,8 +1013,11 @@ def ban_user(user_id, v): continue x.ban(admin=v, reason=reason, days=days) + duration = "permanently" if days: days_txt = str(days).rstrip('.0') + duration = f"for {days_txt} day" + if days != 1: duration += "s" if reason: text = f"@{v.username} (Admin) has banned you for **{days_txt}** days for the following reason:\n\n> {reason}" else: text = f"@{v.username} (Admin) has banned you for **{days_txt}** days." else: @@ -1018,10 +1025,6 @@ def ban_user(user_id, v): else: text = f"@{v.username} (Admin) has banned you permanently." send_repeatable_notification(user.id, text) - - if days == 0: duration = "permanently" - elif days == 1: duration = "for 1 day" - else: duration = f"for {days_txt} days" note = f'reason: "{reason}", duration: {duration}' ma=ModAction( diff --git a/files/routes/posts.py b/files/routes/posts.py index 2f3fdadf0..406861a41 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -843,8 +843,8 @@ def submit_post(v, sub=None): if len(url) > 2048: return error("There's a 2048 character limit for URLs.") + bets = [] if v and v.admin_level >= PERMS['POST_BETS']: - bets = [] for i in bet_regex.finditer(body): bets.append(i.group(1)) body = body.replace(i.group(0), "") diff --git a/files/routes/reporting.py b/files/routes/reporting.py index dc7d2baa3..509e84af8 100644 --- a/files/routes/reporting.py +++ b/files/routes/reporting.py @@ -11,9 +11,7 @@ from files.helpers.sanitize import filter_emojis_only @limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{SITE}-{session.get("lo_user")}') @auth_required def flag_post(pid, v): - post = get_post(pid) - reason = request.values.get("reason", "").strip() if blackjack and any(i in reason.lower() for i in blackjack.split()):