From 915d6db634e52e1aa4af08fb26c318b89ed48b69 Mon Sep 17 00:00:00 2001 From: Aevann Date: Tue, 22 Oct 2024 15:21:57 +0300 Subject: [PATCH] linkfy username in ban reason --- files/classes/user.py | 10 +++++----- files/routes/admin.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index 1b0ac6d66..f062616c7 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -1151,15 +1151,15 @@ class User(Base): - def ban(self, admin=None, reason=None, days=0.0, modlog=True, username=None): + def ban(self, admin=None, reason=None, days=0.0, modlog=True, original_user=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 + if not original_user: + original_user = self g.db.add(self) if days: @@ -1172,7 +1172,7 @@ class User(Base): self.is_banned = admin.id if admin else AUTOJANNY_ID - reason += f" (@{username} - {datetime.date.today()})" + reason += f' (@{original_user.username} - {datetime.date.today()})' self.ban_reason = reason if days: @@ -1201,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 02557a04d..2241a8727 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, modlog=False, username=user.username) + x.ban(admin=v, reason=reason, days=days, modlog=False, original_user=user) one_month_ago = time.time() - 2592000 if x.last_active > one_month_ago: send_repeatable_notification(x.id, text)