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:
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' (<a href="/id/{original_user.id}">@{original_user.username}</a> - {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' (<a href="/id/{self.id}">@{self.username}</a> - {datetime.date.today()})'
self.shadowban_reason = reason
ma = ModAction(

View File

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