diff --git a/files/classes/user.py b/files/classes/user.py index f86d7131b..1d9671295 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -677,6 +677,21 @@ class User(Base): def is_suspended(self): return (self.is_banned and (self.unban_utc == 0 or self.unban_utc > time.time())) + @property + @lazy + def has_shadowbanned_alts(self): + qty = g.db.execute( + """SELECT COUNT(*) FROM ( + SELECT (CASE + WHEN user1 = :u THEN user2 + WHEN user2 = :u THEN user1 + END) AS id FROM alts + WHERE user1 = :u OR user2 = :u + ) AS a + JOIN users ON a.id = users.id + WHERE users.shadowbanned IS NOT NULL""", + {"u": self.id}).scalar() + return qty > 0 @property @lazy diff --git a/files/routes/admin.py b/files/routes/admin.py index 1d8fe36ca..a3389fd13 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -930,7 +930,7 @@ def shadowban(user_id, v): g.db.add(user) for alt in user.alts: - if alt.admin_level: break + if alt.admin_level: continue alt.shadowbanned = v.username g.db.add(alt) diff --git a/files/routes/login.py b/files/routes/login.py index 66b891d83..0d4e65df6 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -345,6 +345,10 @@ def sign_up_post(v): check_for_alts(new_user.id) + if new_user.has_shadowbanned_alts: + new_user.shadowbanned = "AutoJanny" + g.db.add(new_user) + g.db.commit() send_notification(new_user.id, WELCOME_MSG)