package calls // Team mode's answers: the retryable 503 for Unknown standing, in each of // the shapes Calls answers in, and the partial list's notice. None of it // is reached outside team mode. import ( "errors" "net/http" "strconv" "time" "amadan.net/oficina/home/roster" "amadan.net/oficina/home/teammode" ) // retryAfter is the roster's own retry interval, in whole seconds, as // every team-mode 503 says it. var retryAfter = strconv.Itoa(int(roster.RetryAfter / time.Second)) // unavailableHeaders are every team-mode 503's: never cached, and when to // ask again. func unavailableHeaders(w http.ResponseWriter) { w.Header().Set("Cache-Control", "no-store") w.Header().Set("Retry-After", retryAfter) } // teamUnavailable is the retryable answer for Unknown standing to a page // or a form: the 503 page (with Try again for a GET) for a request that // asked for a page, plain text for anything else. A 404 would tell a // member their meeting is gone because Home was slow. func (a *app) teamUnavailable(w http.ResponseWriter, r *http.Request) { unavailableHeaders(w) a.errorPage(w, r, http.StatusServiceUnavailable, kindTeam, "") } // teamUnavailableJSON is the same answer to a script — the room's stream, // signal and ICE fetches, the native app — in their JSON shape. room.js // and callscore retry a 5xx with backoff; the body names nothing. func teamUnavailableJSON(w http.ResponseWriter) { unavailableHeaders(w) streamJSON(w, http.StatusServiceUnavailable, map[string]any{"error": "unavailable"}) } // teamUnavailableAPI is the drive surface's. func teamUnavailableAPI(w http.ResponseWriter) { unavailableHeaders(w) apiJSON(w, http.StatusServiceUnavailable, map[string]any{"error": "unavailable"}) } // isTeamUnavailable reports whether err is standing that cannot be // decided now (errTeamUnavailable, or the guard's ErrUnavailable). // Outside team mode no error is ever one. func isTeamUnavailable(err error) bool { return errors.Is(err, teammode.ErrUnavailable) } // requestPartial reports whether this request's own standing is Unknown // now, which is the partial-list rule (Paul, 2026-10-28, Home // implementation/teammode-package.md §4): the list asks it after it is // built, of the same Access it was built with — State latches, so a lease // that lapsed while listing marks the list partial. Without standing a // member reaches no meeting at all (Calls has no per-person shares of a // meeting: a guest's grant is for one call, and a guest has no list), so // a partial list is always empty, and the notice is what keeps it from // reading as "no meetings". NotMember is never partial: it never reaches // the list. Always false outside team mode. func (a *app) requestPartial(r *http.Request) bool { t, ok := teamReqFrom(r.Context()) return a.team != nil && ok && t.access.Partial() } // The partial notice (Paul, 2026-10-28): what the meeting list says when // the roster could not be read within its lease. const ( partialTitle = "We couldn’t check your team access" partialBody = "Your team’s meetings can’t be shown until it’s checked, so this list is not complete. Try again in a moment." ) // guardRefused answers a write the guard refused, and reports whether it // did: standing lapsed between the route's gate and the commit, the same // retryable 503 as Unknown anywhere else, and the 404 for a definite "no" // (which one request's Access cannot reach once it has said Member, but // costs nothing to answer correctly). Outside team mode no error is ever // one of these. func (a *app) guardRefused(w http.ResponseWriter, r *http.Request, err error) bool { switch { case errors.Is(err, teammode.ErrUnavailable): a.teamUnavailable(w, r) case errors.Is(err, teammode.ErrNotMember): a.notFound(w, r) default: return false } return true }