linkfy username in ban reason

master
Aevann 2024-10-22 15:21:57 +03:00
parent 6854ed1d09
commit 915d6db634
2 changed files with 6 additions and 6 deletions

View File

@ -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: if self.is_permabanned:
return return
if len(reason) > BAN_REASON_HTML_LENGTH_LIMIT: if len(reason) > BAN_REASON_HTML_LENGTH_LIMIT:
stop(400, "Rendered ban reason is too long!") stop(400, "Rendered ban reason is too long!")
if not username: if not original_user:
username = self.username original_user = self
g.db.add(self) g.db.add(self)
if days: if days:
@ -1172,7 +1172,7 @@ class User(Base):
self.is_banned = admin.id if admin else AUTOJANNY_ID self.is_banned = admin.id if admin else AUTOJANNY_ID
reason += f" (@{username} - {datetime.date.today()})" reason += f' (<a href="/id/{original_user.id}">@{original_user.username}</a> - {datetime.date.today()})'
self.ban_reason = reason self.ban_reason = reason
if days: if days:
@ -1201,7 +1201,7 @@ class User(Base):
self.shadowbanned = admin.id if admin else AUTOJANNY_ID self.shadowbanned = admin.id if admin else AUTOJANNY_ID
reason += f" (@{self.username} - {datetime.date.today()})" reason += f' (<a href="/id/{self.id}">@{self.username}</a> - {datetime.date.today()})'
self.shadowban_reason = reason self.shadowban_reason = reason
ma = ModAction( ma = ModAction(

View File

@ -1051,7 +1051,7 @@ def ban_user(fullname, v):
for x in get_alt_graph(user.id): for x in get_alt_graph(user.id):
if x.admin_level > v.admin_level: if x.admin_level > v.admin_level:
continue 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 one_month_ago = time.time() - 2592000
if x.last_active > one_month_ago: if x.last_active > one_month_ago:
send_repeatable_notification(x.id, text) send_repeatable_notification(x.id, text)