remotes/1693045480750635534/spooky-22
Aevann1 2022-01-29 04:01:16 +02:00
parent 70813c686a
commit 38e853250e
2 changed files with 53 additions and 52 deletions

View File

@ -34,45 +34,47 @@ def check_for_alts(current_id):
if past_id == MOM_ID or current_id == MOM_ID: break
if past_id == current_id: continue
check1 = g.db.query(Alt).filter_by(
user1=current_id, user2=past_id).one_or_none()
check2 = g.db.query(Alt).filter_by(
user1=past_id, user2=current_id).one_or_none()
li = [past_id, current_id]
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).one_or_none()
if not check1 and not check2:
try:
new_alt = Alt(user1=past_id, user2=current_id)
g.db.add(new_alt)
g.db.flush()
except: pass
if not existing:
new_alt = Alt(user1=past_id, user2=current_id)
g.db.add(new_alt)
g.db.flush()
alts = g.db.query(Alt)
otheralts = alts.filter(or_(Alt.user1 == past_id, Alt.user2 == past_id, Alt.user1 == current_id, Alt.user2 == current_id)).all()
otheralts = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).all()
for a in otheralts:
existing = alts.filter_by(user1=a.user1, user2=past_id).one_or_none()
if not existing:
new_alt = Alt(user1=a.user1, user2=past_id)
g.db.add(new_alt)
g.db.flush()
if a.user1 != past_id:
li = [a.user1, past_id]
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).one_or_none()
if not existing:
new_alt = Alt(user1=a.user1, user2=past_id)
g.db.add(new_alt)
g.db.flush()
existing = alts.filter_by(user1=a.user1, user2=current_id).one_or_none()
if not existing:
new_alt = Alt(user1=a.user1, user2=current_id)
g.db.add(new_alt)
g.db.flush()
if a.user1 != current_id:
li = [a.user1, current_id]
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).one_or_none()
if not existing:
new_alt = Alt(user1=a.user1, user2=current_id)
g.db.add(new_alt)
g.db.flush()
existing = alts.filter_by(user1=a.user2, user2=past_id).one_or_none()
if not existing:
new_alt = Alt(user1=a.user2, user2=past_id)
g.db.add(new_alt)
g.db.flush()
if a.user2 != past_id:
li = [a.user2, past_id]
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).one_or_none()
if not existing:
new_alt = Alt(user1=a.user2, user2=past_id)
g.db.add(new_alt)
g.db.flush()
existing = alts.filter_by(user1=a.user2, user2=current_id).one_or_none()
if not existing:
new_alt = Alt(user1=a.user2, user2=current_id)
g.db.add(new_alt)
g.db.flush()
if a.user2 != current_id:
li = [a.user2, current_id]
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).one_or_none()
if not existing:
new_alt = Alt(user1=a.user2, user2=current_id)
g.db.add(new_alt)
g.db.flush()
@app.post("/login")

View File

@ -1010,23 +1010,22 @@ def saved_comments(v, username):
@app.post("/fp/<fp>")
@auth_required
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:
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()
if existing: continue
new_alt = Alt(user1=v.id, user2=u.id)
g.db.add(new_alt)
g.db.flush()
print('\n\n' + v.username + ' + ' + u.username + '\n\n')
g.db.add(v)
g.db.commit()
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:
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()
if existing: continue
new_alt = Alt(user1=v.id, user2=u.id)
g.db.add(new_alt)
g.db.flush()
print(v.username + ' + ' + u.username)
g.db.add(v)
g.db.commit()
return '', 204