aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-01-12 20:16:35 +0000
committerAdam Soltys <[email protected]>2024-01-12 20:16:37 +0000
commit6f36b0a9c1b47ed624f59ca769d41ca868aef054 (patch)
tree0501961a203cc33f1b6c669f5a9cb592841f31e1
parent2444b62a4d254121bab0314972e260d839a18993 (diff)
downloadcoinos-server-6f36b0a9c1b47ed624f59ca769d41ca868aef054.tar.gz
coinos-server-6f36b0a9c1b47ed624f59ca769d41ca868aef054.zip
handle missing payments
-rw-r--r--routes/payments.js4
-rw-r--r--routes/users.js3
2 files changed, 6 insertions, 1 deletions
diff --git a/routes/payments.js b/routes/payments.js
index dc6eb292..b9273120 100644
--- a/routes/payments.js
+++ b/routes/payments.js
@@ -89,6 +89,10 @@ export default {
await Promise.all(
payments.map(async (id) => {
let p = await g(`payment:${id}`);
+ if (!p) {
+ warn("missing payment", id);
+ return p;
+ }
if (p.created < start || p.created > end) return;
if (p.type === types.internal) p.with = await g(`user:${p.ref}`);
return p;
diff --git a/routes/users.js b/routes/users.js
index 2299094f..a0a0dcf9 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -55,7 +55,7 @@ export default {
for await (let k of db.scanIterator({ MATCH: "balance:*" })) {
let uid = k.split(":")[1];
- let user = await g(`user:${uid}`);
+ let user = await getUser(uid);
if (!user) {
await db.del(`balance:${uid}`);
@@ -69,6 +69,7 @@ export default {
let total = 0;
for (let pid of payments) {
let p = await g(`payment:${pid}`);
+ if (!p) continue;
total += p.amount;
if (p.amount < 0) total -= (p.fee || 0) + (p.ourfee || 0);
}