From eb1a246da8465f6f2796a76a364ed5ab02270a1b Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:49:24 -0400 Subject: [PATCH] Create upload status check endpoint --- functions/api/uploads/[[id]].ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/functions/api/uploads/[[id]].ts b/functions/api/uploads/[[id]].ts index 178d22f..41a2209 100644 --- a/functions/api/uploads/[[id]].ts +++ b/functions/api/uploads/[[id]].ts @@ -1,14 +1,4 @@ export async function onRequestGet(context: RequestContext) { - const { current_user: currentUser } = context.data; - - if (!(currentUser?.permissions & (1 << 5))) - return new Response('{"error":"Forbidden"}', { - headers: { - "content-type": "application/json", - }, - status: 403, - }); - const attachment = context.params.id as string; const unsignedURL = `https://mediaproxy.carcrushers.cc/${attachment}?Expires=${( Math.round(Date.now() / 1000) + 1800 @@ -33,3 +23,13 @@ export async function onRequestGet(context: RequestContext) { .replaceAll("=", "")}` ); } + +export async function onRequestHead(context: RequestContext) { + const attachment = context.params.id as string; + + return new Response(null, { + status: (await context.env.DATA.get(`videoprocessing_${attachment}`)) + ? 409 + : 204, + }); +}