forked from MarseyWorld/MarseyWorld
Propagate shadows to new alts on signup.
parent
3238a78eb1
commit
0fbb102929
|
@ -690,6 +690,21 @@ class User(Base):
|
||||||
def is_suspended(self):
|
def is_suspended(self):
|
||||||
return (self.is_banned and (self.unban_utc == 0 or self.unban_utc > time.time()))
|
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
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
|
|
|
@ -930,7 +930,7 @@ def shadowban(user_id, v):
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
|
|
||||||
for alt in user.alts:
|
for alt in user.alts:
|
||||||
if alt.admin_level: break
|
if alt.admin_level: continue
|
||||||
alt.shadowbanned = v.username
|
alt.shadowbanned = v.username
|
||||||
g.db.add(alt)
|
g.db.add(alt)
|
||||||
|
|
||||||
|
|
|
@ -345,6 +345,10 @@ def sign_up_post(v):
|
||||||
|
|
||||||
|
|
||||||
check_for_alts(new_user.id)
|
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)
|
send_notification(new_user.id, WELCOME_MSG)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue