activation hook: fire Loomio+Matrix syncs at first broker login

New members were skipped by the syncs until their Cloudron account was
activated (deliberately - never invite a half-created account), but nothing
fired the syncs at the moment they DID activate: the 3x/day sweep was the
only pickup, so a newly-activated member could wait hours for forum/space
access (limdingwen waited ~5h on 2026-11-06).

Hook the broker identity path (_verify_broker_secret): after an active
member resolves, if loomio_invited_at is still null, confirm their Cloudron
account is activated (inviteAccepted, fail-CLOSED - an unreadable user list
never fires) and run the same idempotent syncs the sweep runs, as a
background task off the response. Established members pay one indexed
SELECT; concurrent first-logins collapse into one run via an inflight flag;
each service is independently best-effort so a Loomio outage cannot block
the Matrix invite or the response.

Tests: tests/test_first_login_sync.py (18 checks, fixture db + stubbed
network). Also fix test_allowance_shortfall, whose expected exclusion
reference still asserted the pre-a88ca86 placeholder.

Sweep, provisioning and deactivation paths are untouched.
This commit is contained in:
inference-bot committed 2026-11-06 19:51:12 +00:00
1 parent a88ca860d4
commit ed66d73327
4 files changed
+348 -2

No files matched your search

+11
View File
@@ -107,6 +107,17 @@ Three jobs run inside the container via `CloudronManifest.json` → `addons.sche
lapsed members, syncs Loomio + Matrix. Idempotent; a missed webhook
self-heals within a day. The same sweep also runs the payment-driven
allowance reconciliation (below).
**First-login activation hook:** the sweep is also the backstop for service
invites, but it is no longer the only trigger. When a member first presents
themselves on the broker identity path (the dashboard's first login), the
portal checks — only if their Loomio invite is still outstanding
(`loomio_invited_at` is null) — that their Cloudron account is now activated
(`inviteAccepted`), and if so fires the same idempotent Loomio + Matrix syncs
as a background task. Established members cost one SELECT; the response never
waits on Loomio or Matrix; failures are logged and non-fatal; unactivated
accounts are never invited (the check fails closed). So a new member gets
forum + Space access at their first login instead of at the next sweep.
- **rag_refresh** (daily 3:30am UTC) — `rag_refresh.py` pulls this repo's
sibling docs from the Gitea raw API (public, no credentials), uploads changed
files to Open WebUI (`OWUI_API_KEY`), attaches them to the shared knowledge