diff --git a/files/classes/user.py b/files/classes/user.py index 0399c1bfb..820b34a20 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -720,6 +720,11 @@ class User(Base): def is_suspended(self): return (self.is_banned and (self.unban_utc == 0 or self.unban_utc > time.time())) + @property + @lazy + def is_suspended_permanently(self): + return (self.is_banned and self.unban_utc == 0) + @property @lazy def has_shadowbanned_alts(self): diff --git a/files/helpers/wrappers.py b/files/helpers/wrappers.py index beca91316..7ffaea636 100644 --- a/files/helpers/wrappers.py +++ b/files/helpers/wrappers.py @@ -138,7 +138,7 @@ def is_not_permabanned(f): check_ban_evade(v) - if v.is_banned and v.unban_utc == 0: + if v.is_suspended_permanently: return {"error": "Internal server error"}, 500 return make_response(f(*args, v=v, **kwargs)) diff --git a/files/routes/users.py b/files/routes/users.py index abc9a9342..1bf374133 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -722,9 +722,7 @@ def message2(v, username): @limiter.limit("1/second;6/minute;50/hour;200/day", key_func=lambda:f'{SITE}-{session.get("lo_user")}') @auth_required def messagereply(v): - body = request.values.get("body", "").strip().replace('‎','') - body = body.replace('\r\n', '\n')[:10000] if not body and not request.files.get("file"): return {"error": "Message is empty!"} @@ -735,6 +733,9 @@ def messagereply(v): parent = get_comment(id, v=v) user_id = parent.author.id + if v.is_suspended_permanently and parent.sentto != 2: + return {"error": "You are permabanned and may not reply to messages."} + if parent.sentto == 2: user_id = None elif v.id == user_id: user_id = parent.sentto