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

+4 -2
View File
@@ -109,9 +109,11 @@ check("reason names the cycle",
"allowance shortfall, truncated paid cycle 2026-10-07→2026-11-02 (OC billing alignment)")
# --- the manual-remediation exclusion is keyed on the charge ref alone
# --- (no member PII in this public repo; identity/timeline live in ops docs)
# --- (no member PII in this public repo; identity/timeline live in ops docs;
# --- the OC tx id IS the reference key and was approved as such — see the
# --- commit that restored it to match the deployed image)
check("remediated charge excluded by reference",
"[redacted member reference]" in SHORTFALL_REMEDIATED, True)
"tx_Kr6n3rW577OSjr2bIt5IC" in SHORTFALL_REMEDIATED, True)
print(f"\n{'FAILED' if failures else 'OK'} — {failures} failure(s)")
sys.exit(1 if failures else 0)