Filter crew events to only be visible for crew

This commit is contained in:
Hornwitser 2025-03-10 16:26:52 +01:00
parent 13f344472e
commit 4806343250
9 changed files with 96 additions and 17 deletions

View file

@ -1,5 +1,14 @@
import { readSchedule } from "~/server/database";
import { readAccounts, readSchedule } from "~/server/database";
import { Account } from "~/shared/types/account";
import { canSeeCrew } from "../utils/schedule";
export default defineEventHandler(async (event) => {
return await readSchedule();
const session = await getAccountSession(event);
let account: Account | undefined;
if (session) {
const accounts = await readAccounts()
account = accounts.find(account => account.id === session.accountId);
}
const schedule = await readSchedule();
return canSeeCrew(account?.type) ? schedule : filterSchedule(schedule);
})