Move userid validator to ban endpoint

This commit is contained in:
2023-10-19 16:49:14 -04:00
parent debb8d9209
commit 75c38e9cc5
2 changed files with 22 additions and 8 deletions

View File

@ -1,6 +1,14 @@
export async function onRequestPost(context: RequestContext) {
const { current_user: currentUser } = context.data;
if (context.data.targetId.search(/^\d{16,19}$/) === -1)
return new Response('{"error":"Invalid target id"}', {
headers: {
"content-type": "application/json",
},
status: 400,
});
await context.env.DATA.put(
`appealban_${context.data.targetId}`,
JSON.stringify({ moderator: currentUser.id })