initial commit
Some checks failed
deploy / build-and-deploy (push) Failing after 21s

This commit is contained in:
2025-05-18 13:16:20 +02:00
commit 60f3f8a096
148 changed files with 17900 additions and 0 deletions

80
src/actions/report.ts Normal file
View File

@ -0,0 +1,80 @@
import { defineAction } from 'astro:actions';
import { Session } from '@util/session.ts';
import { Permissions } from '@util/permissions.ts';
import { db } from '@db/database.ts';
import { z } from 'astro:schema';
export const report = {
addReport: defineAction({
input: z.object({
reason: z.string(),
body: z.string().nullable(),
createdAt: z.string().datetime().nullable(),
reporter: z.number(),
reported: z.number().nullable()
}),
handler: async (input, context) => {
Session.actionSessionFromCookies(context.cookies, Permissions.Reports);
const { id } = await db.addReport({
reason: input.reason,
body: input.body,
createdAt: input.createdAt,
reporterTeamId: input.reporter,
reportedTeamId: input.reported
});
return {
id: id
};
}
}),
reportStatus: defineAction({
input: z.object({
reportId: z.number()
}),
handler: async (input, context) => {
Session.actionSessionFromCookies(context.cookies, Permissions.Reports);
return {
reportStatus: await db.getReportStatus(input)
};
}
}),
editReportStatus: defineAction({
input: z.object({
reportId: z.number(),
status: z.enum(['open', 'closed']).nullable(),
notice: z.string().nullable(),
statement: z.string().nullable(),
strikeId: z.number().nullable()
}),
handler: async (input, context) => {
Session.actionSessionFromCookies(context.cookies, Permissions.Reports);
await db.editReportStatus(input);
}
}),
reports: defineAction({
input: z.object({
reporter: z.string().nullish(),
reported: z.string().nullish()
}),
handler: async (input, context) => {
Session.actionSessionFromCookies(context.cookies, Permissions.Reports);
return {
reports: await db.getReports(input)
};
}
}),
strikeReasons: defineAction({
handler: async (_, context) => {
Session.actionSessionFromCookies(context.cookies, Permissions.Reports);
return {
strikeReasons: await db.getStrikeReasons({})
};
}
})
};