Merge branch 'frost' of https://github.com/Aevann1/Drama into frost

master
Aevann1 2022-07-09 12:32:52 +02:00
commit 8590456eaa
3 changed files with 20 additions and 1 deletions

View File

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

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)