aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-28 19:26:13 -0800
committerAdam Soltys <[email protected]>2026-02-28 19:26:13 -0800
commit205ffb7684f18256690f374ab78745ccfe5d850d (patch)
tree2defac29b4579a3aa67ec536b6aef0d6452b91fe /routes
parentcaf1f126d0569670712e26fa2f6ac3127605cd91 (diff)
downloadcoinos-server-205ffb7684f18256690f374ab78745ccfe5d850d.tar.gz
coinos-server-205ffb7684f18256690f374ab78745ccfe5d850d.zip
fix hono route order
Diffstat (limited to 'routes')
-rw-r--r--routes/payments.ts12
-rw-r--r--routes/users.ts28
2 files changed, 32 insertions, 8 deletions
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}`);
+ l("deleteAccount account:", !!account, "type:", account?.type);
+ if (!account) fail("account not found");
- const pos = await db.lPos(`${uid}:accounts`, id);
- if (!(account && pos != null)) 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) {