Add GET endpoint for inactivity-notice-by-id
This commit is contained in:
parent
bde4727d9f
commit
84e7df6c30
@ -29,6 +29,32 @@ export async function onRequestDelete(context: RequestContext) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function onRequestGet(context: RequestContext) {
|
||||||
|
const { current_user: currentUser } = context.data;
|
||||||
|
|
||||||
|
if (
|
||||||
|
![1 << 0, 1 << 2, 1 << 3, 1 << 9, 1 << 10].find(
|
||||||
|
(p) => currentUser.permissions & p,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return jsonError("Forbidden", 403);
|
||||||
|
|
||||||
|
const result: Record<
|
||||||
|
string,
|
||||||
|
string | number | { [k: string]: string }
|
||||||
|
> | null = await context.env.D1.prepare(
|
||||||
|
"SELECT * FROM inactivity_notices WHERE id = ?;",
|
||||||
|
)
|
||||||
|
.bind(context.params.id)
|
||||||
|
.first();
|
||||||
|
|
||||||
|
if (!result) return jsonError("Inactivity notice does not exist", 404);
|
||||||
|
|
||||||
|
result.user = JSON.parse(result.user as string);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
export async function onRequestPost(context: RequestContext) {
|
export async function onRequestPost(context: RequestContext) {
|
||||||
const { accepted }: { accepted?: boolean } = context.data.body;
|
const { accepted }: { accepted?: boolean } = context.data.body;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user