This commit is contained in:
2000-Trek 2023-06-21 21:03:12 +02:00
parent 5a954ecdae
commit 55148a6929

16
main.py
View file

@ -261,24 +261,20 @@ 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[1]})")
c.execute(f"INSERT OR IGNORE INTO tags (tagid, userid) VALUES ({tag_id}, {user[0]})")
message = tag_id
finished = queue_item
c.execute(f"SELECT * FROM users WHERE id={user[1]}")
username = c.fetchall()
conn.commit()
return make_response(json.dumps({"mode":"2","username":username,"code":"1"}))
return make_response(json.dumps({"mode":"2","username":user[1],"code":"1"}))
elif state == "remove":
c.execute(f"SELECT * FROM tags WHERE (tagid = {tag_id} AND userid = {user[1]})")
c.execute(f"SELECT * FROM tags WHERE (tagid = {tag_id} AND userid = {user[0]})")
tags = c.fetchall()
if tags != []:
c.execute(f"DELETE FROM tags WHERE (tagid = {tag_id} AND userid = {user[1]}) ")
c.execute(f"DELETE FROM tags WHERE (tagid = {tag_id} AND userid = {user[0]}) ")
message = tag_id
finished = queue_item
c.execute(f"SELECT * FROM users WHERE id={user[1]}")
username = c.fetchall()
conn.commit()
return make_response(json({"mode":"2","username":username,"code":"2"}))
return make_response(json({"mode":"2","username":user[1],"code":"2"}))
else:
message = "Tag does not exist"
finished = queue_item
@ -292,8 +288,6 @@ 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")