From 3806dc23afb003055f004bf51811db4e75eb2c80 Mon Sep 17 00:00:00 2001 From: soxa <6390896+Soxasora@users.noreply.github.com> Date: Thu, 5 Dec 2024 15:15:08 +0100 Subject: [PATCH] enhance: show an error when uploads are expired (#1685) * enhance: show an error when uploads are expired * lint: standardjs --- api/paidAction/itemCreate.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/api/paidAction/itemCreate.js b/api/paidAction/itemCreate.js index 4b2b8bb9..9f6a23fb 100644 --- a/api/paidAction/itemCreate.js +++ b/api/paidAction/itemCreate.js @@ -38,6 +38,16 @@ export async function perform (args, context) { const { tx, me, cost } = context const boostMsats = satsToMsats(boost) + const deletedUploads = [] + for (const uploadId of uploadIds) { + if (!await tx.upload.findUnique({ where: { id: uploadId } })) { + deletedUploads.push(uploadId) + } + } + if (deletedUploads.length > 0) { + throw new Error(`upload(s) ${deletedUploads.join(', ')} are expired, consider reuploading.`) + } + let invoiceData = {} if (invoiceId) { invoiceData = { invoiceId, invoiceActionState: 'PENDING' }