Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't include user emails in lookup by id endpoint
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent c187b68 commit a3f65a3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions functions/api/mod-queue/[type]/[id].ts
Expand Up @@ -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" &&
Expand All @@ -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",
},
Expand Down

0 comments on commit a3f65a3

Please sign in to comment.