Finish appeal[id] middleware

This commit is contained in:
regalijan 2023-10-19 16:49:13 -04:00
parent 55817306d2
commit 75005da3b3
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -10,15 +10,18 @@ export async function onRequestPost(context: RequestContext) {
}); });
const { body } = context.data; const { body } = context.data;
const id = context.params.id as string;
if (typeof body.accept !== "boolean") if (id.search(/^\d{16,19}$/) === -1)
return new Response('{"error":"Invalid acceptance status"}', { return new Response('{"error":"Invalid target id"}', {
headers: { headers: {
"content-type": "application/json", "content-type": "application/json",
}, },
status: 400, status: 400,
}); });
context.data.targetId = id;
if ( if (
body.feedback && body.feedback &&
(typeof body.feedback !== "string" || body.feedback.length > 512) (typeof body.feedback !== "string" || body.feedback.length > 512)
@ -29,4 +32,6 @@ export async function onRequestPost(context: RequestContext) {
}, },
status: 400, status: 400,
}); });
return await context.next();
} }