aboutsummaryrefslogtreecommitdiffstats
path: root/routes/users.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-02-26 11:59:58 -0800
committerAdam Soltys <[email protected]>2025-02-26 11:59:58 -0800
commit1d541fd97210389f006e65d46ab783afbe82cea8 (patch)
tree66781ea2992fa99198ed1e450cdb9b68acfbc4d9 /routes/users.ts
parenta14b987a392bc700975b048f37838da08e4ed255 (diff)
downloadcoinos-server-1d541fd97210389f006e65d46ab783afbe82cea8.tar.gz
coinos-server-1d541fd97210389f006e65d46ab783afbe82cea8.zip
payment types
Diffstat (limited to 'routes/users.ts')
-rw-r--r--routes/users.ts16
1 files changed, 14 insertions, 2 deletions
diff --git a/routes/users.ts b/routes/users.ts
index 106cfd4a..515e64f0 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -6,7 +6,7 @@ import { db, g, s } from "$lib/db";
import { err, l, warn } from "$lib/logging";
import { mail, templates } from "$lib/mail";
import { getNostrUser, getProfile, serverPubkey } from "$lib/nostr";
-import { reconcile, types } from "$lib/payments";
+import { reconcile } from "$lib/payments";
import register from "$lib/register";
import { emit } from "$lib/sockets";
import upload from "$lib/upload";
@@ -19,6 +19,8 @@ import { getPublicKey, nip19, verifyEvent } from "nostr-tools";
import { authenticator } from "otplib";
import { v4 } from "uuid";
+import type { Payment, PaymentType } from "$lib/types";
+
export default {
upload,
@@ -465,7 +467,7 @@ export default {
await Promise.all(
payments.reverse().map(async (id) => await g(`payment:${id}`)),
)
- ).filter((p) => p && p.type === types.internal && p.ref)) {
+ ).filter((p) => p && p.type === PaymentType.internal && p.ref)) {
if (ref === id) continue;
const i = contacts.findIndex((c) => c && c.id === ref);
if (~i) contacts.splice(i, 1);
@@ -817,6 +819,16 @@ export default {
async app(req, res) {
const { pubkey } = req.params;
const app = await g(`app:${pubkey}`);
+
+ let payments = (await db.lRange(`${pubkey}:payments`, 0, -1)) || [];
+ payments = await Promise.all(payments.map((hash) => g(`payment:${hash}`)));
+
+ await Promise.all(
+ payments.map(async (p: Payment) => (p.user = await g(`user:${p.uid}`))),
+ );
+
+ app.payments = payments.filter((p) => p);
+
res.send(app);
},