feat(sessions): material downloads unlock when the session ends

Private materials bucket + RLS read gate (admins/own speakers anytime, all
attendees after the scheduled slot end, event-local Amsterdam time); always
visible uploaded-state, locked download panel, authenticated client downloads,
admin signed URLs. 12 new assertions in material_time_lock_tests.sql.

Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
committed 2026-10-21 18:57:15 +02:00
1 parent 7776145a77
commit a8f3f5b8e1
13 files changed
+334 -30

No files matched your search

+24
View File
@@ -610,6 +610,30 @@ in `transform-excel.test.js`; verified against the real Sessionize demo payload
(10/11 sessions get a language, service sessions stay null → now forced
English by the RPCs).
## Material downloads unlock at the session end — ✅ complete (2026-10-21)
Product rule (Sabrina): uploaded session material must not distract attendees
mid-session, but must be available to **everyone** (time-based, attendance not
required) once the session's schedule ends — and users must always *see* that
a speaker uploaded material even while the download is locked.
- **Enforced at the storage layer**, not the UI: `20261021180000_material_time_lock.sql`
makes the `materials` bucket **private** and replaces `materials_read` with
`can_read_session_material(bucket, name)`: admins and the session's own
speakers anytime; everyone else only after `slot_date + end_time`
(Europe/Amsterdam wall time, matching the client's existing `slotStatus ===
'done'` rule). A leaked path/URL releases nothing early.
- **Always-visible existence**: the agenda card 📎 pill already renders from
`material_path` (unchanged, `get_agenda` still returns it); SessionDetail
shows a "📎 Material uploaded — unlocks at HH:MM" panel (`material-locked`)
while locked, and a download button once unlocked or for the speaker.
- **Clients**: attendee app downloads via authenticated
`storage.from('materials').download()` (blob + filename); admin app switched
to short-lived `createSignedUrl`. No `getPublicUrl` remains in any app.
- **Tests**: `supabase/tests/material_time_lock_tests.sql` — 12 assertions
(bucket private, outsider locked/unlocked by time, speaker/admin bypass,
malformed/foreign-bucket rejection, event-local boundary, anon exclusion).
## Known work (open as of 2026-10-19)
- **E2E seed drift — 42 specs currently red.** The pretix reseed removed the