Prevent permabanned users from replying to DMs.

Permabanning already prevents users from initiating new DMs, and we
complete this by preventing replying to existing DM chains.
New modmails may still be initiated, and existing modmails may still
be replied to.
master
Snakes 2022-09-01 16:19:07 -04:00
parent eff9c29025
commit ba05430a80
3 changed files with 9 additions and 3 deletions

View File

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

View File

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

View File

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