Initial commit
This commit is contained in:
27
functions/api/reports/recall.ts
Normal file
27
functions/api/reports/recall.ts
Normal file
@ -0,0 +1,27 @@
|
||||
export async function onRequestPost(context: RequestContext) {
|
||||
const { id } = context.data.body;
|
||||
|
||||
if (!id)
|
||||
return new Response('{"error":"No ID provided"}', {
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
status: 400,
|
||||
});
|
||||
|
||||
const reportUserId = await context.env.DATA.get(`reportprocessing_${id}`);
|
||||
|
||||
if (!reportUserId || context.data.current_user.id !== reportUserId)
|
||||
return new Response('{"error":"No processing report with that ID found"}', {
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
status: 404,
|
||||
});
|
||||
|
||||
await context.env.DATA.delete(`report_${id}`);
|
||||
|
||||
return new Response(null, {
|
||||
status: 204,
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user