diff options
| author | Adam Soltys <[email protected]> | 2023-04-06 10:57:18 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-04-06 10:57:18 -0700 |
| commit | 3f7bcceaa075ebf5f7ed41276a5be0ae2d168ff6 (patch) | |
| tree | 98dbb0b39b86dec222ca29e58bc23fc5e5d47c2e /routes | |
| parent | 924c83701a02f043041d7dbb27ce8d77c6829c6b (diff) | |
| download | coinos-server-3f7bcceaa075ebf5f7ed41276a5be0ae2d168ff6.tar.gz coinos-server-3f7bcceaa075ebf5f7ed41276a5be0ae2d168ff6.zip | |
fix tips
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/users.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/routes/users.js b/routes/users.js index f4e68d1e..1e4d00cc 100644 --- a/routes/users.js +++ b/routes/users.js @@ -442,12 +442,18 @@ export default { res.send({}); }, - async lower(req, res) { - for await (let k of db.scanIterator({ MATCH: "user:*" })) { - let u = await g(k); - if (u.pin && !u.haspin) { - u.haspin = true; - s(k, u); + async fix(req, res) { + if (!req.user.admin) fail("unauthorized"); + let uid = await g("user:laughingbean"); + let payments = await db.lRange(`${uid}:payments`, 0, -1); + + for (let hash of payments) { + let payment = await g(`payment:${hash}`); + let invoice = await g(`invoice:${hash}`); + if (!invoice) continue; + if (invoice.amount !== payment.amount) { + payment.amount -= payment.tip; + s(`payment:${hash}`, payment); } } |
