fix: increment total_calls on every metered call (audit finding)

This commit is contained in:
drjones
2026-10-02 07:14:32 -07:00
parent 48414b1a7b
commit f6f7be5e51

View File

@@ -434,6 +434,7 @@ def consume(user, kind, detail="", ip=""):
c.close()
return False, "Out of credits. Free tier: %d/mo. Buy more at %s/pricing" % (
CFG["free_monthly"], CFG["base_url"])
c.execute("UPDATE users SET total_calls=total_calls+1 WHERE id=?", (user["id"],))
c.execute("INSERT INTO usage_log (user_id, api_key, ip, kind, detail) VALUES (?,?,?,?,?)",
(user["id"], user["api_key"], ip, kind, detail[:200]))
else: