Skip to content

Commit

Permalink
better fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Nov 14, 2024
1 parent b7fc0e0 commit 03ec61f
Show file tree
Hide file tree
Showing 22 changed files with 475 additions and 321 deletions.
4 changes: 2 additions & 2 deletions api/paidAction/boost.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ export async function perform ({ invoiceId, sats, id: itemId, ...args }, { me, c
}

export async function retry ({ invoiceId, newInvoiceId }, { tx, cost }) {
await tx.itemAct.updateMany({ where: { invoiceId }, data: { invoiceId: newInvoiceId, invoiceActionState: 'PENDING' } })
const [{ id, path }] = await tx.$queryRaw`
SELECT "Item".id, ltree2text(path) as path
FROM "Item"
JOIN "ItemAct" ON "Item".id = "ItemAct"."itemId"
WHERE "ItemAct"."invoiceId" = ${newInvoiceId}::INTEGER`
WHERE "ItemAct"."invoiceId" = ${invoiceId}::INTEGER`
await tx.itemAct.updateMany({ where: { invoiceId }, data: { invoiceId: newInvoiceId, invoiceActionState: 'PENDING' } })
return { id, sats: msatsToSats(cost), act: 'BOOST', path }
}

Expand Down
4 changes: 2 additions & 2 deletions api/paidAction/downZap.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ export async function perform ({ invoiceId, sats, id: itemId }, { me, cost, tx }
}

export async function retry ({ invoiceId, newInvoiceId }, { tx, cost }) {
await tx.itemAct.updateMany({ where: { invoiceId }, data: { invoiceId: newInvoiceId, invoiceActionState: 'PENDING' } })
const [{ id, path }] = await tx.$queryRaw`
SELECT "Item".id, ltree2text(path) as path
FROM "Item"
JOIN "ItemAct" ON "Item".id = "ItemAct"."itemId"
WHERE "ItemAct"."invoiceId" = ${newInvoiceId}::INTEGER`
WHERE "ItemAct"."invoiceId" = ${invoiceId}::INTEGER`
await tx.itemAct.updateMany({ where: { invoiceId }, data: { invoiceId: newInvoiceId, invoiceActionState: 'PENDING' } })
return { id, sats: msatsToSats(cost), act: 'DONT_LIKE_THIS', path }
}

Expand Down
Loading

0 comments on commit 03ec61f

Please sign in to comment.