Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make complete endpoint actually work
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 5f9dfb7 commit bdeb84d
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions functions/api/reports/complete.ts
Expand Up @@ -26,14 +26,17 @@ export async function onRequestPost(context: RequestContext) {

await context.env.DATA.delete(`reportprocessing_${id}`);

const {
metadata,
value,
}: KVNamespaceGetWithMetadataResult<string, { [k: string]: any }> =
await context.env.DATA.getWithMetadata(`report_${id}`);

delete metadata?.p;
await context.env.DATA.put(`report_${id}`, value as string, { metadata });
const value = await context.env.DATA.get(`report_${id}`);

if (!value)
return new Response('{"error":"Report is missing"}', {
headers: {
"content-type": "application/json",
},
status: 500,
});

await context.env.DATA.put(`report_${id}`, value as string);

if (context.env.REPORTS_WEBHOOK) {
await fetch(context.env.REPORTS_WEBHOOK, {
Expand Down

0 comments on commit bdeb84d

Please sign in to comment.