1
0
Fork 0
forked from bton/matekasse

End hat Jason komplizierter gemacht

This commit is contained in:
2000-Trek 2023-07-15 14:42:40 +02:00
parent d8951d3ecf
commit 7458f0be35

12
main.py
View file

@ -306,7 +306,7 @@ def get_id():
queue_item = users.get() queue_item = users.get()
user = queue_item[0] user = queue_item[0]
state = queue_item[1] state = queue_item[1]
c.execute(f"SELECT * FROM users WHERE id={user}") c.execute(f"SELECT * FROM users WHERE id=?", [user])
username = c.fetchall()[0][1] username = c.fetchall()[0][1]
if state == "add": if state == "add":
c.execute(f"SELECT * FROM tags WHERE tagid={tag_id}") c.execute(f"SELECT * FROM tags WHERE tagid={tag_id}")
@ -315,22 +315,22 @@ def get_id():
finished = queue_item finished = queue_item
return make_response(json.dumps({"mode":"error","error":"170"})) return make_response(json.dumps({"mode":"error","error":"170"}))
else: else:
c.execute(f"INSERT OR IGNORE INTO tags (tagid, userid) VALUES ({tag_id}, {user})") c.execute(f"INSERT OR IGNORE INTO tags (tagid, userid) VALUES ({tag_id}, ?)", [user])
message = f"Added {tag_id} to {username}" message = f"Added {tag_id} to {username}"
db_log.info(message) db_log.info(message)
finished = queue_item finished = queue_item
conn.commit() conn.commit()
return make_response(json.dumps({"mode":"message","username":username,"message":"A tag was added"})) return make_response(json.dumps({"mode":"message","username":"%s".format(username),"message":"A tag was added"}))
elif state == "remove": elif state == "remove":
c.execute(f"SELECT * FROM tags WHERE (tagid = {tag_id} AND userid = {user})") c.execute(f"SELECT * FROM tags WHERE (tagid = {tag_id} AND userid = ?)", [user])
tags = c.fetchall() tags = c.fetchall()
if tags != []: if tags != []:
c.execute(f"DELETE FROM tags WHERE (tagid = {tag_id} AND userid = {user}) ") c.execute(f"DELETE FROM tags WHERE (tagid = {tag_id} AND userid = ?)", [user])
message = f"Removed {tag_id} from {username}" message = f"Removed {tag_id} from {username}"
db_log.info(message) db_log.info(message)
finished = queue_item finished = queue_item
conn.commit() conn.commit()
return make_response(json.dumps({"mode":"message","username":username,"message":"A tag was removed"})) return make_response(json.dumps({"mode":"message","username":"%s".format(username),"message":"A tag was removed"}))
else: else:
message = "054" message = "054"
finished = queue_item finished = queue_item