forked from MarseyWorld/MarseyWorld
fix def shadowban() and def ban()
parent
f62e726c3c
commit
4d6c5df4eb
|
@ -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(
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue