diff --git a/files/classes/user.py b/files/classes/user.py index 4eceb47ab..1b0ac6d66 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -1151,13 +1151,16 @@ class User(Base): - def ban(self, admin=None, reason=None, days=0.0, modlog=True): + def ban(self, admin=None, reason=None, days=0.0, modlog=True, username=None): if self.is_permabanned: return if len(reason) > BAN_REASON_HTML_LENGTH_LIMIT: stop(400, "Rendered ban reason is too long!") + if not username: + username = self.username + g.db.add(self) if days: if self.unban_utc: @@ -1169,7 +1172,7 @@ class User(Base): self.is_banned = admin.id if admin else AUTOJANNY_ID - reason += f" (@{self.username} {datetime.date.today()})" + reason += f" (@{username} - {datetime.date.today()})" self.ban_reason = reason if days: @@ -1198,7 +1201,7 @@ class User(Base): self.shadowbanned = admin.id if admin else AUTOJANNY_ID - reason += f" (@{self.username} {datetime.date.today()})" + reason += f" (@{self.username} - {datetime.date.today()})" self.shadowban_reason = reason ma = ModAction( diff --git a/files/routes/admin.py b/files/routes/admin.py index 9488bd7a6..02557a04d 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1051,7 +1051,7 @@ def ban_user(fullname, v): for x in get_alt_graph(user.id): if x.admin_level > v.admin_level: continue - x.ban(admin=v, reason=reason, days=days) + x.ban(admin=v, reason=reason, days=days, modlog=False, username=user.username) one_month_ago = time.time() - 2592000 if x.last_active > one_month_ago: send_repeatable_notification(x.id, text)