Guest state: the overview payload carries the definitive display state

Single derivation point (tested once, here): 'invited' while the Cloudron
invite is unaccepted, else the guests-ledger status (the record of record),
membership state only as a no-ledger-row fallback. The panel and dashboard
become pure consumers of `state` — their local invited/active derivation
goes away in their own repos next. Live-behaviour note: today's four live
guests render byte-identically; the change only shows for ended guests
(ledger 'expired' instead of the bare inactive flag), which is what the
panel already displayed via its own guest_status preference.
This commit is contained in:
inference-bot committed 2026-11-11 05:16:13 +00:00
1 parent 62a59477c6
commit 58214be0db
2 files changed
+44 -5

No files matched your search

+14 -1
View File
@@ -4787,7 +4787,9 @@ async def admin_overview(request: Request):
# until acceptance flips it. Display/state semantics only: access
# rules, the $2 cap and the expiry box are unchanged (an unaccepted
# guest cannot reach anything anyway — the setup link is the only
# door in).
# door in). This override is half of the SINGLE guest-state
# derivation (see the guest_status block below for the other half);
# the panel and dashboard consume `state` and derive nothing.
sent = (guest_info.get(email) or {}).get("sent")
mstate = "invited"
mstate_reason = (f"awaiting setup — invite sent {str(sent)[:10]}, "
@@ -4821,6 +4823,17 @@ async def admin_overview(request: Request):
gi = guest_info.get(email) or {}
entry["guest_inviter"] = gi.get("inviter")
entry["guest_status"] = gi.get("status")
# The other half of the SINGLE guest-state derivation (portal =
# source of truth; tested once in tests/test_guest_invited_state.py,
# consumed as-is by the panel and dashboard). Once the invite is
# accepted the guests-ledger status IS the display state — the
# record of record (active / converted / expired / depleted /
# cancelled by recipient) — so an ended guest reads its ledger
# status, not the bare active/inactive membership flag. A guest
# with no ledger row keeps the membership state as the fallback.
if entry["state"] != "invited" and gi.get("status"):
entry["state"] = gi["status"]
entry["state_reason"] = ""
if email.lower() in OPERATOR_EMAILS:
# Operator accounts: surfaced under a separate "admin" category in
# the panel, excluded from member counts and aggregates (their