diff options
| author | Adam Soltys <[email protected]> | 2025-09-18 16:38:32 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-09-18 16:38:32 -0700 |
| commit | 1347f87dcd92d318fbdd9d364648bc32ee52b4a7 (patch) | |
| tree | 4667a87859446ca1f7494a3196190e18ec5f7ade /routes | |
| parent | 8c7fa95d44aabd38fadc3ef955d835ad3379ec6c (diff) | |
| parent | 3ec79e2f938423d1442886454204973d804f37d9 (diff) | |
| download | coinos-server-1347f87dcd92d318fbdd9d364648bc32ee52b4a7.tar.gz coinos-server-1347f87dcd92d318fbdd9d364648bc32ee52b4a7.zip | |
Merge branch 'patch-1'
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/invoices.ts | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/routes/invoices.ts b/routes/invoices.ts index 430c926d..7e98599e 100644 --- a/routes/invoices.ts +++ b/routes/invoices.ts @@ -53,11 +53,18 @@ export default { try { const { id } = req.params; const { body } = req; - if (body.invoice?.tip == null || body.invoice.tip < 0) fail("Invalid tip"); + const { tip, webhook, secret } = body.invoice; + if (tip == null || tip < 0) fail("Invalid tip"); let invoice = await g(`invoice:${id}`); - const user = await g(`user:${invoice.uid}`); - invoice.tip = body.invoice.tip; + const user = req.user || (await g(`user:${invoice.uid}`)); + + if (tip) invoice.tip = tip; + if (invoice.uid === user?.id) { + if (webhook) invoice.webhook = webhook; + if (secret) invoice.secret = secret; + } + invoice = await generate({ invoice, user }); await s(`invoice:${id}`, invoice); |
