diff --git a/main.py b/main.py index 5167ddf..276ed39 100644 --- a/main.py +++ b/main.py @@ -285,7 +285,9 @@ def api_change(): if change == None: change = 1 c.execute(f"UPDATE users SET balance = balance + {change} WHERE id={user[0]}") - db_log.info(f"Changed the balance from user {user[0]} from {balance_old} to {user[2]}") + c.execute(f"SELECT * FROM users WHERE id = {userid}") + user_new = c.fetchall()[0] + db_log.info(f"Changed the balance from user {user[0]} from {user[2]} to {user_new[2]}") socketio.emit("update", "update") return make_response(json.dumps({"mode":"balance", "username":user[1], "balance":user[2]})) diff --git a/templates/documentation.html b/templates/documentation.html index 576ead3..d80a895 100644 --- a/templates/documentation.html +++ b/templates/documentation.html @@ -12,6 +12,19 @@

Documentation

http://matekasse.server.c3h/api/tag_id?={tag_id}

+

Response: + {"mode":"error" "error":"{error}"} + {"mode":"message","username":"{username}","message":"{message}"} + {"mode":"balance", "username":"{username}", "balance":"{balance}"} +

+

+

http://matekasse.server.c3h/api/change?id={user_id}?change={change}

+

+ If change = None the change will be 1 + Response: + {"mode":"error" "error":"{error}"} + {"mode":"balance", "username":"{username}", "balance":"{balance}"} +

 

API: