diff options
| author | Adam Soltys <[email protected]> | 2024-09-12 15:34:20 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-09-12 15:34:20 -0700 |
| commit | b00fee005fc69f79d300fa71a3619d97f4571c23 (patch) | |
| tree | 2b535b49cf1f136ce30d573bd8e17b49ab78ddbf /lib | |
| parent | f76ffaf514d42f9d74698d9fddc2e98e54667578 (diff) | |
| download | coinos-server-b00fee005fc69f79d300fa71a3619d97f4571c23.tar.gz coinos-server-b00fee005fc69f79d300fa71a3619d97f4571c23.zip | |
default account
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/invoices.ts | 2 | ||||
| -rw-r--r-- | lib/migrate.ts | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/invoices.ts b/lib/invoices.ts index 0919c948..c18a120b 100644 --- a/lib/invoices.ts +++ b/lib/invoices.ts @@ -37,6 +37,8 @@ export let generate = async ({ invoice, user, sender = undefined }) => { else if (sender) user = await getUser(sender.username); if (!user) fail("user not provided"); + if (account === user.id) account = undefined; + let rates = await g("rates"); if (!currency) currency = user.currency; if (!rate) rate = rates[currency]; diff --git a/lib/migrate.ts b/lib/migrate.ts index c6de972c..8896f54b 100644 --- a/lib/migrate.ts +++ b/lib/migrate.ts @@ -13,7 +13,15 @@ async function migrate(id) { let user = await g(`user:${id}`); if (typeof user === "string") user = await g(`user:${user}`); - if (user) return user; + if (user) { + let accounts = await db.lLen(`${user.id}:accounts`); + if (!accounts) { + await s(`account:${user.id}`, { id: user.id }); + await db.lPush(`${user.id}:accounts`, user.id); + } + + return user; + } user = await ga(`user:${id}`); |
