Propagate shadows to new alts on signup.

remotes/1693045480750635534/spooky-22
Snakes 2022-07-09 05:25:15 -04:00
parent 3238a78eb1
commit 0fbb102929
3 changed files with 20 additions and 1 deletions

View File

@ -690,6 +690,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

View File

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

View File

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