From 205ffb7684f18256690f374ab78745ccfe5d850d Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 28 Feb 2026 19:26:13 -0800 Subject: fix hono route order --- routes/payments.ts | 12 ++++++++++++ routes/users.ts | 30 +++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 9 deletions(-) (limited to 'routes') diff --git a/routes/payments.ts b/routes/payments.ts index 0689f57d..beae4d1a 100644 --- a/routes/payments.ts +++ b/routes/payments.ts @@ -953,6 +953,18 @@ export default { if (!gotLock) return c.json({ synced: 0, received: 0, payments: [] }); try { + // Sync ark address if client reports a different one + if (body.arkAddress) { + const account = await g(`account:${aid}`); + if (account && account.arkAddress !== body.arkAddress) { + if (account.arkAddress) await db.del(`arkaddr:${account.arkAddress}`); + account.arkAddress = body.arkAddress; + await s(`account:${aid}`, account); + await db.set(`arkaddr:${body.arkAddress}`, JSON.stringify({ aid, uid })); + l("arkSync updated arkAddress for", aid); + } + } + const { rate, currency } = await getUserRate(user); let synced = 0; diff --git a/routes/users.ts b/routes/users.ts index 4d07a288..9ebe3614 100644 --- a/routes/users.ts +++ b/routes/users.ts @@ -1010,10 +1010,22 @@ export default { const body = await c.req.json(); const { id } = body; const { id: uid } = c.get("user"); + l("deleteAccount", id, "uid:", uid); const account = await g(`account:${id}`); - - const pos = await db.lPos(`${uid}:accounts`, id); - if (!(account && pos != null)) fail("account not found"); + l("deleteAccount account:", !!account, "type:", account?.type); + if (!account) fail("account not found"); + + // Support both list and set storage for accounts + const keyType = await db.type(`${uid}:accounts`); + if (keyType === "list") { + const pos = await db.lPos(`${uid}:accounts`, id); + if (pos == null) fail("account not found"); + } else if (keyType === "set") { + const isMember = await db.sIsMember(`${uid}:accounts`, id); + if (!isMember) fail("account not found"); + } else { + fail("account not found"); + } if (account.type !== "ark") { try { @@ -1024,12 +1036,12 @@ export default { } } - await db - .multi() - .lRem(`${uid}:accounts`, 1, id) - .del(`account:${id}`) - .del(`${id}:payments`) - .exec(); + const m = db.multi(); + if (keyType === "list") m.lRem(`${uid}:accounts`, 1, id); + else if (keyType === "set") m.sRem(`${uid}:accounts`, id); + m.del(`account:${id}`).del(`${id}:payments`); + if (account.arkAddress) m.del(`arkaddr:${account.arkAddress}`); + await m.exec(); return c.json({ ok: true }); } catch (e) { -- cgit v1.2.3