23 lines
612 B
TypeScript
23 lines
612 B
TypeScript
import { jsonError } from "../../common.js";
|
|
|
|
export async function onRequestPost(context: RequestContext) {
|
|
const { id } = context.data.body;
|
|
|
|
if (!id) return jsonError("No ID provided", 400);
|
|
|
|
const reportUserId = await context.env.DATA.get(`reportprocessing_${id}`);
|
|
|
|
if (
|
|
!reportUserId ||
|
|
(context.data.current_user?.id !== reportUserId &&
|
|
context.request.headers.get("CF-Connecting-IP") !== reportUserId)
|
|
)
|
|
return jsonError("No processing report with that ID found", 404);
|
|
|
|
await context.env.DATA.delete(`report_${id}`);
|
|
|
|
return new Response(null, {
|
|
status: 204,
|
|
});
|
|
}
|