23 lines
604 B
TypeScript
23 lines
604 B
TypeScript
import { jsonError } from "../../common.js";
|
|
|
|
export async function onRequestPost(context: RequestContext) {
|
|
const { active } = context.data.body;
|
|
const { permissions } = context.data.current_user;
|
|
|
|
if (!(permissions & (1 << 0)) && !(permissions & (1 << 11)))
|
|
return jsonError("Forbidden", 403);
|
|
|
|
if (typeof active !== "boolean")
|
|
return jsonError("Active property must be a boolean", 400);
|
|
|
|
if (active) {
|
|
await context.env.DATA.delete("appeal_disabled");
|
|
} else {
|
|
await context.env.DATA.put("appeal_disabled", "1");
|
|
}
|
|
|
|
return new Response(null, {
|
|
status: 204,
|
|
});
|
|
}
|