From a3f65a397de4aa7d41faafdd67c598ab7092d0ec Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:50:44 -0400 Subject: [PATCH] Don't include user emails in lookup by id endpoint --- functions/api/mod-queue/[type]/[id].ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/functions/api/mod-queue/[type]/[id].ts b/functions/api/mod-queue/[type]/[id].ts index 9f0167a..0766eb0 100644 --- a/functions/api/mod-queue/[type]/[id].ts +++ b/functions/api/mod-queue/[type]/[id].ts @@ -33,10 +33,16 @@ export async function onRequestGet(context: RequestContext) { status: 403, }); - let item = await context.env.DATA.get(`${types[type].prefix}${itemId}`); + let item: { + [k: string]: any; + } | null = await context.env.DATA.get(`${types[type].prefix}${itemId}`, { + type: "json", + }); if (!item) - item = await context.env.DATA.get(`closed${types[type].prefix}${itemId}`); + item = await context.env.DATA.get(`closed${types[type].prefix}${itemId}`, { + type: "json", + }); if ( type === "report" && @@ -49,7 +55,9 @@ export async function onRequestGet(context: RequestContext) { status: 409, }); - return new Response(item ? item : '{"error":"Not found"}', { + if (item) delete item.user?.email; + + return new Response(item ? JSON.stringify(item) : '{"error":"Not found"}', { headers: { "content-type": "application/json", },