This commit is contained in:
2000-Trek 2023-06-21 21:06:07 +02:00
parent 55148a6929
commit 8ae5fe8988

16
main.py
View file

@ -261,20 +261,24 @@ def get_id():
finished = queue_item
return make_response(json.dumps({"mode":"0","error":"170"}))
else:
c.execute(f"INSERT OR IGNORE INTO tags (tagid, userid) VALUES ({tag_id}, {user[0]})")
c.execute(f"INSERT OR IGNORE INTO tags (tagid, userid) VALUES ({tag_id}, {user})")
message = tag_id
finished = queue_item
c.execute(f"SELECT * FROM users WHERE id={user}")
username = c.fetchall()
conn.commit()
return make_response(json.dumps({"mode":"2","username":user[1],"code":"1"}))
return make_response(json.dumps({"mode":"2","username":username,"code":"1"}))
elif state == "remove":
c.execute(f"SELECT * FROM tags WHERE (tagid = {tag_id} AND userid = {user[0]})")
c.execute(f"SELECT * FROM tags WHERE (tagid = {tag_id} AND userid = {user})")
tags = c.fetchall()
if tags != []:
c.execute(f"DELETE FROM tags WHERE (tagid = {tag_id} AND userid = {user[0]}) ")
c.execute(f"DELETE FROM tags WHERE (tagid = {tag_id} AND userid = {user}) ")
message = tag_id
finished = queue_item
c.execute(f"SELECT * FROM users WHERE id={user}")
username = c.fetchall()
conn.commit()
return make_response(json({"mode":"2","username":user[1],"code":"2"}))
return make_response(json({"mode":"2","username":username,"code":"2"}))
else:
message = "Tag does not exist"
finished = queue_item
@ -288,6 +292,8 @@ def get_id():
if users.qsize() == 0:
c.execute(f"UPDATE users SET balance = balance - 1 WHERE id={tag[1]}")
conn.commit()
c.execute(f"SELECT * FROM users WHERE id={tag[1]}")
user = c.fetchall()[0]
socketio.emit("update", "upfinished = queue_itemdate")
return make_response(json.dumps({"mode":"1", "username":user[1], "balance":user[2]}))
socketio.emit("update", "update")