| 1 | package memoria |
| 2 | |
| 3 | // Team mode's answers: the retryable 503 for Unknown standing and the |
| 4 | // partial-list notice. Neither is reached outside team mode. |
| 5 | |
| 6 | import ( |
| 7 | "net/http" |
| 8 | "strconv" |
| 9 | "time" |
| 10 | |
| 11 | "amadan.net/oficina/home/roster" |
| 12 | ) |
| 13 | |
| 14 | // teamUnavailable is the retryable answer for Unknown standing: the app's |
| 15 | // own 503 page (or the plain status for anything that did not ask for a |
| 16 | // page — the native API, the search fragment's fetch), never cached, with |
| 17 | // Retry-After. A 404 would tell a team member a document is gone because |
| 18 | // Home was slow. |
| 19 | // |
| 20 | // no-store is errorPage's, on the page and the plain answer alike; the |
| 21 | // tests assert it on every one of these. |
| 22 | func (a *app) teamUnavailable(w http.ResponseWriter, r *http.Request) { |
| 23 | w.Header().Set("Retry-After", strconv.Itoa(int(roster.RetryAfter/time.Second))) |
| 24 | a.errorPage(w, r, http.StatusServiceUnavailable, kindStatus, "") |
| 25 | } |
| 26 | |
| 27 | // The partial notice (Paul, 2026-10-28): what a list page says when the |
| 28 | // roster could not be read within its lease. Memoria has no shares, so the |
| 29 | // partial list is always empty — and the notice is what keeps that from |
| 30 | // reading as "nothing matched" or "nothing stored", which this codebase |
| 31 | // treats as the worst failure shape it has. |
| 32 | const ( |
| 33 | partialTitle = "We couldn’t check your team access" |
| 34 | partialBody = "Nothing from the team’s memory can be shown until it’s checked. Try again in a moment." |
| 35 | ) |
| 36 | |
| 37 | // partialNotice is the notice's two sentences, for the templates. |
| 38 | type partialNotice struct{ Title, Body string } |
| 39 | |
| 40 | func (page) PartialNotice() partialNotice { return partialNotice{partialTitle, partialBody} } |
| 41 | |
| 42 | // withhold empties every list on p built from the team's memory and marks |
| 43 | // it partial: what a list page shows when teamPartial says the standing |
| 44 | // it was built on did not hold to the end. Everything Memoria lists is the |
| 45 | // team rung, so nothing survives it. |
| 46 | func (p *page) withhold() { |
| 47 | p.Partial = true |
| 48 | p.Results, p.Documents, p.Notices = nil, nil, nil |
| 49 | p.Facts, p.Explained, p.FactsDeferred = nil, nil, false |
| 50 | p.AnswerSlot, p.Answer = false, nil |
| 51 | p.Primed = false |
| 52 | p.Recent, p.RecentNotices, p.Try = nil, nil, nil |
| 53 | p.Chunks = -1 |
| 54 | } |
| 55 | |
| 56 | // withhold is page.withhold for the reports page, whose two lists are its |
| 57 | // own. |
| 58 | func (p *reportsPage) withhold() { |
| 59 | p.page.withhold() |
| 60 | p.Reports, p.Feedback = nil, nil |
| 61 | } |
| 62 | |