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,4 +1,5 @@
import { Account } from '~/shared/types/account';
import { Schedule } from '~/shared/types/schedule';
import { readSchedule, writeSchedule } from '~/server/database';
import { broadcastUpdate } from '~/server/streams';
@ -17,5 +18,17 @@ export async function updateScheduleInterestedCounts(accounts: Account[]) {
}
}
await writeSchedule(schedule);
broadcastUpdate(schedule);
await broadcastUpdate(schedule);
}
export function canSeeCrew(accountType: string | undefined) {
return accountType === "crew" || accountType === "admin";
}
/** Filters out crew visible only parts of schedule */
export function filterSchedule(schedule: Schedule): Schedule {
return {
locations: schedule.locations,
events: schedule.events.filter(event => !event.crew),
}
}