diff options
| author | Adam Soltys <[email protected]> | 2023-03-27 21:09:22 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-03-27 21:09:22 -0700 |
| commit | 0559a382066722b794e1aaaafbb24266c7302f9e (patch) | |
| tree | ac390cb5f44f1d878f72760c89d8ee01f583e939 /lib/invoices.js | |
| parent | 5756d04533a69d93091dcbb469d83da6b55456bc (diff) | |
| download | coinos-server-0559a382066722b794e1aaaafbb24266c7302f9e.tar.gz coinos-server-0559a382066722b794e1aaaafbb24266c7302f9e.zip | |
strip spaces from usernames
Diffstat (limited to 'lib/invoices.js')
| -rw-r--r-- | lib/invoices.js | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/invoices.js b/lib/invoices.js index 95a81104..74870f82 100644 --- a/lib/invoices.js +++ b/lib/invoices.js @@ -2,7 +2,7 @@ import store from "$lib/store"; import { l } from "$lib/logging"; import { emit } from "$lib/sockets"; import { db, g, s } from "$lib/db"; -import { bip21, fail } from "$lib/utils"; +import { getUser, bip21, fail } from "$lib/utils"; import { types } from "$lib/payments"; import { v4 } from "uuid"; @@ -18,8 +18,7 @@ export let generate = async ({ invoice, user, sender, memo }) => { if (amount < 0) fail("amount out of range"); if (!user) user = sender; - let uid = await g(`user:${user.username.toLowerCase()}`); - user = await g(`user:${uid}`); + user = await getUser(user.username); if (!user) fail("user not provided"); @@ -64,13 +63,13 @@ export let generate = async ({ invoice, user, sender, memo }) => { text, tip, type, - uid, + uid: user.id }; l("creating invoice", user.username, amount, tip, currency, invoice.hash); await s(`invoice:${hash}`, invoice); - await db.lPush(`${uid}:invoices`, hash); + await db.lPush(`${user.id}:invoices`, hash); if (request_id) { let request = await g(`request:${request_id}`); |
