diff options
author | Raphael Kabo <raphaelkabo@hey.com> | 2024-02-05 20:56:00 +0000 |
---|---|---|
committer | Raphael Kabo <raphaelkabo@hey.com> | 2024-02-05 21:47:14 +0000 |
commit | f11a16ea501ca7f792337751a0365215ac7aafc4 (patch) | |
tree | 11bf1daa55e9a3c513d2124af8d817d558126eea /src/routes/frontend.ts | |
parent | 2b47f4f8141820835c778ea748f8ae7f47ef261d (diff) |
Backwards compatibility for attendee visibility
Diffstat (limited to 'src/routes/frontend.ts')
-rw-r--r-- | src/routes/frontend.ts | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/routes/frontend.ts b/src/routes/frontend.ts index 23418df..8ddfbf6 100644 --- a/src/routes/frontend.ts +++ b/src/routes/frontend.ts @@ -142,7 +142,11 @@ router.get("/:eventID", async (req: Request, res: Response) => { if (el.number && el.number > 1) { el.name = `${el.name} (${el.number} people)`; } - return el; + return { + ...el, + // Backwards compatibility - if visibility is not set, default to public + visibility: el.visibility || "public", + }; }) .filter((obj, pos, arr) => { return ( @@ -159,13 +163,13 @@ router.get("/:eventID", async (req: Request, res: Response) => { } return acc; }, 0) || 0; - const visibleAttendees = event.attendees?.filter( + const visibleAttendees = eventAttendees?.filter( (attendee) => attendee.visibility === "public", ); - const hiddenAttendees = event.attendees?.filter( + const hiddenAttendees = eventAttendees?.filter( (attendee) => attendee.visibility === "private", ); - const numberOfHiddenAttendees = event.attendees?.reduce( + const numberOfHiddenAttendees = eventAttendees?.reduce( (acc, attendee) => { if ( attendee.status === "attending" && |