oficina / calendar Public

Clone
git clone https://amadan.net/oficina/calendar

Plain git — no account needed to clone.

Download

Download this file

1package calendar
2
3// Team mode's subscription feeds. A feed URL is a capability (Home
4// teammode-package.md §7.3: "Published .ics feed tokens stay capability
5// links"), but what it reads, it reads on its MINTER's standing, asked on
6// every poll — exactly as a presentation in Slides stands on its presenter
7// (oficina/slides #33). So:
8//
9// - Member: the calendar, as before.
10// - NotMember: the feed is gone, the same 404 as a revoked or unknown
11// token. A member taken off the team stops receiving the team's
12// calendar within the lease, in every account they pasted the URL
13// into, without anybody having to find and revoke it. Re-added, the
14// URL works again; the token was never touched.
15// - Unknown: 503, no-store, Retry-After. A subscriber (Google, Apple,
16// Outlook) is a cross-origin reader that cannot see a partial notice,
17// so it must never be served a short calendar (Paul's ruling,
18// 2026-10-28, condition 3). Those clients keep the copy they last
19// fetched when a poll fails, so a 503 is "keep the last good feed"
20// without this server rendering anything under Unknown or storing a
21// plaintext copy to replay (which the one rule forbids).
22//
23// Standing is read before the calendar is (the stream-order lesson), and
24// again after the feed is built: a lease that lapsed in between is a 503,
25// never a calendar some of whose events were withheld.
26
27import (
28 "context"
29 "net/http"
30
31 "amadan.net/oficina/home/roster"
32 "amadan.net/oficina/home/teammode"
33)
34
35// feedStanding decides a feed's poll on its minter's standing and returns
36// the context its reads run on. Outside team mode it is r's own context
37// and true.
38func (h *handlers) feedStanding(w http.ResponseWriter, r *http.Request, f Feed) (context.Context, bool) {
39 if h.team == nil {
40 return r.Context(), true
41 }
42 acc := h.standingFor(r.Context(), f.PersonID)
43 switch acc.State() {
44 case roster.Member:
45 return teammode.WithAccess(r.Context(), acc), true
46 case roster.NotMember:
47 http.NotFound(w, r)
48 default:
49 teamUnavailablePlain(w)
50 }
51 return nil, false
52}
53
54// feedNotFound answers a feed whose calendar the minter no longer reaches:
55// the 404 it has always been, unless the minter's standing lapsed while
56// reading, which is a retry.
57func (h *handlers) feedNotFound(w http.ResponseWriter, r *http.Request, ctx context.Context) {
58 if standingLapsed(ctx) {
59 teamUnavailablePlain(w)
60 return
61 }
62 http.NotFound(w, r)
63}
64
65// standingLapsed reports whether the standing a feed's (or a booking
66// page's) reads ran on is no longer Member. Always false outside team mode
67// (no Access on ctx is carried there, and none is asked for).
68func standingLapsed(ctx context.Context) bool {
69 acc, ok := teammode.FromContext(ctx)
70 return ok && acc.State() != roster.Member
71}
72