feat(programs): "Add to calendar" export for program events#952
Open
jee7s wants to merge 1 commit into
Open
Conversation
Signed-in users viewing a program can export its event schedule: a program-level .ics (hand-rolled RFC 5545, no new dependency) plus per-event Google Calendar template links on the detail page. - lib/calendar/ics.ts: VCALENDAR/VEVENT builder (stable UID, DTSTAMP, DTSTART/DTEND in UTC, SUMMARY/DESCRIPTION/LOCATION, CRLF endings, TEXT escaping, 75-char folding, missing-end + all-day handling) and a client-safe googleCalendarEventUrl(). - GET /api/programs/[id]/calendar.ics via withAuth: reads only Program + Event rows (no roster), gated exactly like the program's visibility (member-only mirrors GET /api/programs/[id]), so it stays off the routeAuthDrift EDGE_INCLUDE_ALLOWLIST by construction. - programs/[id] page: a Schedule card with the .ics download and per-event Google links, shown to signed-in viewers when the program has events. No schema change. Design: docs/designs/PROGRAM_CALENDAR_EXPORT.md. Tests: 16 unit (ICS builder) + 8 integration (route auth + content). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Signed-in users viewing a program had no way to get its sessions into their own
calendar — the
Eventrows carryname/startAt/endAt/descriptionbut neversurfaced outside staff views. This adds an "Add to calendar" affordance on the
program detail page:
.ics(hand-rolled RFC 5545, no new dependency) with allthe program's events, and
Design doc:
checkin-app/docs/designs/PROGRAM_CALENDAR_EXPORT.md.Decisions (from the product interview)
API credentials, no subscribable live feed (deferred — see the doc §7).
/programs/[id]for signed-in users who cansee the program (not a page/email/kiosk surface).
Eventrows — one.icsper program + per-event links.Authorization posture
The export is gated like the program's visibility, not its roster. The
catalog route
GET /api/programs/[id]already returns the program'seventstoany caller who clears its visibility gate (event fields are
@sensitivity:public),so the schedule is public-catalog data. The new route:
Programscalars +Eventrows — noProgramParticipant/ProgramVolunteer/RSVP/Visit— so there is no roster to leak and itstays off
routeAuthDrift'sEDGE_INCLUDE_ALLOWLISTby construction;withAuth(mandatory session → 401 anon, 403 kiosk);orgMemberOnlygate (member-only schedules go onlyto the lead mentor / sysadmin / board / active member; others get 403).
One deliberate simplification (documented in the route header + doc §4): the
program route also treats core volunteers as privileged via a
ProgramVolunteerread; this route omits that branch to stay roster-free, since a core volunteer who
isn't also a member is rare and still has the per-event Google links / an admin's copy.
Implementation
checkin-app/src/lib/calendar/ics.ts—buildIcs()(VCALENDAR/VEVENT, stableUID,DTSTAMP,DTSTART/DTENDin UTC,SUMMARY/DESCRIPTION/LOCATION,CRLF endings, TEXT escaping of
\ ; ,+ newlines, 75-char folding, missing-endgoogleCalendarEventUrl(). Pure, no deps.checkin-app/src/app/api/programs/[id]/calendar.ics/route.ts— the download route.checkin-app/src/app/programs/[id]/page.tsx— a Schedule card with the.icsdownload button and per-event Google Calendar links (signed-in + has-events).
No schema change, no migration, no new dependency, no external call.
Testing
src/lib/calendar/ics.test.ts): escaping, CRLF, structure,UTC formatting, missing-end, all-day (
VALUE=DATE), folding, Google URL.src/app/__tests__/programCalendarICS.integration.test.ts):401 anon;
text/calendar+Content-Dispositionattachment for a publicprogram; empty-program VCALENDAR; member-only gate (403 non-member, 200 for
member/admin/lead); 404 missing / 400 unparseable id.
routeAuthDriftguard green (route needs no allowlist entry). Full pre-commitsuite green (1695 tests),
tsc --noEmitandeslint --max-warnings 0clean.🤖 Generated with Claude Code