| 1 | package calendar |
| 2 | |
| 3 | // Team mode's public booking pages. A published page is a live free/busy |
| 4 | // oracle over every calendar its host can see (AGENTS.md, "What this rule |
| 5 | // does NOT cover" 5), the team calendar included, and a hold or a move |
| 6 | // writes onto the host's calendar. So the page, its picker, the hold, the |
| 7 | // confirmation and a reschedule all stand on the HOST's standing, asked on |
| 8 | // every request — as a presentation in Slides stands on its presenter |
| 9 | // (oficina/slides #33): |
| 10 | // |
| 11 | // - Member: as before, with the host's Access carried so busy time is |
| 12 | // read through the host's own reach and every write is guarded on it. |
| 13 | // - NotMember: the page is gone, the router's own 404, as an unpublished |
| 14 | // one is. A member taken off the team stops publishing the team's |
| 15 | // free/busy within the lease. |
| 16 | // - Unknown: 503, no-store, Retry-After; never a picker built from less |
| 17 | // than the host's whole busy list (B23), and the picker asks again |
| 18 | // after it is built (handlers_booking_public.go). |
| 19 | // |
| 20 | // A booker's own booking — its manage page, its .ics, and cancelling it — |
| 21 | // is theirs by its token and stands on nobody's standing: those writes are |
| 22 | // systemWrite. Mail to the host is decided at delivery (team_jobs.go). |
| 23 | |
| 24 | import ( |
| 25 | "net/http" |
| 26 | |
| 27 | "amadan.net/oficina/home/roster" |
| 28 | "amadan.net/oficina/home/teammode" |
| 29 | ) |
| 30 | |
| 31 | // hostStanding decides a public booking request on its host's standing |
| 32 | // and returns the request its reads and writes run on. Outside team mode |
| 33 | // it is r and true. |
| 34 | func (h *handlers) hostStanding(w http.ResponseWriter, r *http.Request, host Person) (*http.Request, bool) { |
| 35 | if h.team == nil { |
| 36 | return r, true |
| 37 | } |
| 38 | acc := h.standingFor(r.Context(), host.ID) |
| 39 | switch acc.State() { |
| 40 | case roster.Member: |
| 41 | return r.WithContext(teammode.WithAccess(r.Context(), acc)), true |
| 42 | case roster.NotMember: |
| 43 | notFoundLikeTheRouter(w, r) |
| 44 | default: |
| 45 | teamUnavailablePlain(w) |
| 46 | } |
| 47 | return r, false |
| 48 | } |
| 49 | |
| 50 | // bookersOwn is r for a booker acting on their own booking by its token: |
| 51 | // in team mode its writes are the instance's (systemWrite), standing on |
| 52 | // nobody's lease. Outside team mode it is r. |
| 53 | func (h *handlers) bookersOwn(r *http.Request) *http.Request { |
| 54 | if h.team == nil { |
| 55 | return r |
| 56 | } |
| 57 | return r.WithContext(systemWrite(r.Context())) |
| 58 | } |
| 59 | |