master
Aevann1 2022-01-29 03:20:02 +02:00
parent 528c7b0f85
commit 70813c686a
4 changed files with 18 additions and 13 deletions

View File

@ -529,13 +529,6 @@ class User(Base):
@property
def is_suspended(self):
if self.unban_utc and self.unban_utc < time.time():
self.is_banned = 0
self.unban_utc = 0
self.ban_evade = 0
g.db.add(self)
g.db.commit()
return False
return (self.is_banned and (self.unban_utc == 0 or self.unban_utc > time.time()))

View File

@ -118,12 +118,14 @@ def revert_actions(v, username):
user.is_banned = 0
user.unban_utc = 0
user.ban_evade = 0
send_repeatable_notification(user.id, "Your account has been unbanned!")
g.db.add(user)
for u in user.alts:
u.shadowbanned = None
u.is_banned = 0
u.unban_utc = 0
u.ban_evade = 0
send_repeatable_notification(u.id, "Your account has been unbanned!")
g.db.add(u)
g.db.commit()
@ -935,6 +937,7 @@ def unban_user(user_id, v):
user.unban_utc = 0
user.ban_evade = 0
user.ban_reason = None
send_repeatable_notification(user.id, "Your account has been unbanned!")
g.db.add(user)
for x in user.alts:
@ -942,11 +945,9 @@ def unban_user(user_id, v):
x.unban_utc = 0
x.ban_evade = 0
x.ban_reason = None
send_repeatable_notification(x.id, "Your account has been unbanned!")
g.db.add(x)
send_repeatable_notification(user.id,
"Your account has been reinstated. Please carefully review and abide by the [rules](/sidebar) to ensure that you don't get suspended again.")
ma=ModAction(
kind="unban_user",
user_id=v.id,

View File

@ -168,6 +168,14 @@ def front_all(v):
posts = get_posts(ids, v=v)
if v:
if v.unban_utc and v.unban_utc < time.time():
v.is_banned = 0
v.unban_utc = 0
v.ban_evade = 0
send_repeatable_notification(v.id, "You have been unbanned!")
g.db.add(v)
g.db.commit()
if v.hidevotedon: posts = [x for x in posts if not hasattr(x, 'voted') or not x.voted]
if v.agendaposter_expires_utc and v.agendaposter_expires_utc < time.time():

View File

@ -1013,8 +1013,12 @@ def fp(v, fp):
if v.username != fp:
v.fp = fp
users = g.db.query(User).filter(User.fp == fp, User.id != v.id).all()
if users: print(f'{v.username}: fp {v.fp}')
if v.email and v.is_activated:
users += g.db.query(User).filter(User.email == v.email, User.is_activated, User.id != v.id).all()
alts = g.db.query(User).filter(User.email == v.email, User.is_activated, User.id != v.id).all()
if alts:
print(f'{v.username}: email {v.email}')
users += alts
for u in users:
li = [v.id, u.id]
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).first()
@ -1022,8 +1026,7 @@ def fp(v, fp):
new_alt = Alt(user1=v.id, user2=u.id)
g.db.add(new_alt)
g.db.flush()
if v.email == u.email: print('\n\n' + v.username + ' + ' + u.username + v.email + '\n\n')
if v.fp == u.fp: print('\n\n' + v.username + ' + ' + u.username + v.fp + '\n\n')
print('\n\n' + v.username + ' + ' + u.username + '\n\n')
g.db.add(v)
g.db.commit()
return '', 204