Skip to content
Permalink
75005da3b3
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
37 lines (31 sloc) 923 Bytes
export async function onRequestPost(context: RequestContext) {
const { permissions } = context.data.current_user;
if (!(permissions & (1 << 0)) || !(permissions & (1 << 11)))
return new Response('{"error":"Forbidden"}', {
headers: {
"content-type": "application/json",
},
status: 403,
});
const { body } = context.data;
const id = context.params.id as string;
if (id.search(/^\d{16,19}$/) === -1)
return new Response('{"error":"Invalid target id"}', {
headers: {
"content-type": "application/json",
},
status: 400,
});
context.data.targetId = id;
if (
body.feedback &&
(typeof body.feedback !== "string" || body.feedback.length > 512)
)
return new Response('{"error":"Invalid feedback"}', {
headers: {
"content-type": "application/json",
},
status: 400,
});
return await context.next();
}