Error Codes

This commit is contained in:
2000-Trek 2023-06-21 19:39:13 +02:00
parent d9b0fe5dde
commit a5102a9cd7

18
main.py
View file

@ -258,17 +258,29 @@ def get_id():
c.execute(f"SELECT * FROM tags WHERE tagid={tag_id}") c.execute(f"SELECT * FROM tags WHERE tagid={tag_id}")
if c.fetchall() != []: if c.fetchall() != []:
message = "Tag already exists" message = "Tag already exists"
finished = queue_item
return make_response(json.dumps({"mode":"0","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 = tag_id message = tag_id
finished = queue_item
c.execute(f"SELECT * FROM users WHERE id={user}")
username = c.fetchall()
return make_response(json({"mode":"2","username":username,"code":"1"}))
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 = tag_id message = tag_id
finished = queue_item
c.execute(f"SELECT * FROM users WHERE id={user}")
username = c.fetchall()
return make_response(json({"mode":"2","username":username,"code":"2"}))
else: else:
message = "Tag does not exist" message = "Tag does not exist"
finished = queue_item
return make_response(json.dumps({"mode":"0","error":"054"}))
conn.commit() conn.commit()
finished = queue_item finished = queue_item
socketio.emit("update", "update") socketio.emit("update", "update")
@ -281,10 +293,10 @@ def get_id():
conn.commit() conn.commit()
c.execute(f"SELECT * FROM users WHERE id={tag[1]}") c.execute(f"SELECT * FROM users WHERE id={tag[1]}")
user = c.fetchall()[0] 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") socketio.emit("update", "update")
return make_response(json.dumps({"username":user[1], "balance":user[2]})) return make_response(json.dump({"mode":"0","error":"418"}))
socketio.emit("update", "update")
return make_response("False")
def main(): def main():
atexit.register(exit_handler) atexit.register(exit_handler)