aboutsummaryrefslogtreecommitdiffstats
path: root/routes/payments.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-03-21 00:06:39 -0700
committerAdam Soltys <[email protected]>2023-03-21 00:06:39 -0700
commit469c384e0930dd2b7c0f01c03cca95f86f05277d (patch)
tree17b24286259596987e74913d72e4733ec58c4f1d /routes/payments.js
parentc99665a0a0ac79176726169a49d5f9ebaae325bc (diff)
downloadcoinos-server-469c384e0930dd2b7c0f01c03cca95f86f05277d.tar.gz
coinos-server-469c384e0930dd2b7c0f01c03cca95f86f05277d.zip
ses mail
Diffstat (limited to 'routes/payments.js')
-rw-r--r--routes/payments.js17
1 files changed, 3 insertions, 14 deletions
diff --git a/routes/payments.js b/routes/payments.js
index 1a5bcf76..3c318f2d 100644
--- a/routes/payments.js
+++ b/routes/payments.js
@@ -404,22 +404,11 @@ export default {
async fix({ body: { uid, username }, user }, res) {
try {
if (!user.admin) fail("unauthorized");
-
- if (username) uid = await g(`user:${username.toLowerCase()}`);
- ({ username } = await g(`user:${uid}`));
- let balance = await g(`balance:${uid}`);
-
- let payments = await db.lRange(`${uid}:payments`, 0, -1);
-
- let total = 0;
- for (let pid of payments) {
- let p = await g(`payment:${pid}`);
- total += p.amount;
- if (p.amount < 0) total -= (p.fee || 0) + (p.ourfee || 0);
+ for await (let k of db.scanIterator({ MATCH: "balance:*" })) {
+ let bal = await g(k);
+ if (bal < 0) s(k, 0);
}
- l("corrected balance", username, uid, balance, total);
- await s(`balance:${uid}`, total);
res.send("ok");
} catch (e) {
console.log(e);