Don't include user emails in lookup by id endpoint

This commit is contained in:
regalijan 2023-10-19 16:50:44 -04:00
parent c187b6816b
commit a3f65a397d
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -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",
},