From 5f310c4a422d369d8e8206237f58ab99cf3bc581 Mon Sep 17 00:00:00 2001 From: Jon Breen Date: Sun, 18 Feb 2024 15:49:41 +0000 Subject: [PATCH] Raise state --- src/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 99c293c..7528017 100644 --- a/src/index.ts +++ b/src/index.ts @@ -150,7 +150,15 @@ export default { .prepare("SELECT id FROM urls WHERE state=0"); let result = await submissionIds.all(); if (result.success) { - return new Response(JSON.stringify(result.results)) + let raiseState = await env.DB + .prepare("UPDATE urls SET state=1 WHERE id IN (?)") + .bind(result.results) + .run(); + if (raiseState.success) { + return new Response(JSON.stringify(result.results)) + } else { + return new Response("Failure to raise state of new submissons in ids " + result.results.join(", "), { status: 400 }) + } } else { return new Response(result.error, { status: 500 }); }