feat/enclaves #32
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/enclaves"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Two correctness fixes from review: - promote_first_user_to_admin now returns whether promotion actually happened. The post-register backfill is only invoked when the new user was promoted, matching the spec wording ("after the first user's promotion completes") and avoiding two cross-pool DB queries on every later registration. - backfill_general_membership drops the early-return that fired whenever any member row existed for General. The function is still idempotent (per-row INSERT OR IGNORE, sentinel-gated UPDATE) but can now repair a partial state where membership rows are present but created_by is still 'system'. New test covers this scenario. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>Adds GET /enclaves/discover, POST /enclaves/discover/{id}/join, POST /enclaves/join (by code), POST /enclave/{id}/visibility, and POST/DELETE /enclave/{id}/invite-code. The require_manage helper centralizes the owner-or-admin-or-site-admin gate; rand::Alphanumeric generates 16-char invite codes. Tests cover the public/private discovery split, the bad-code rejection, and the discover-join refusal for private enclaves. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>Adds POST /enclave/{id}/invite (manage-required, idempotent on UNIQUE collision), POST /invitations/{id}/accept and /decline (invitee-only), and GET /invitations rendering the pending list. Two-user test harness app_with_two_users covers the end-to-end invite -> list -> accept -> landing flow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>Adds GET /enclave/{id}/settings (manage-required) and the matching mutation handlers. Owner-self-leave is rejected with a clear message; the only-member case returns the delete-instead error so the user is told to use /delete. Kick refuses to remove the owner role even under site-admin god-mode (the spec mandates transfer-ownership first). The role endpoint accepts only "admin" or "member" form values. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>Adds POST /enclave/{id}/rooms (create), .../rooms/{room_id}/edit, .../delete, .../members (add), and .../members/{user_id}/remove. assert_room_in_enclave guards every per-room handler so a manager of enclave A cannot delete or edit a room living in enclave B (404 instead of leaking that the room exists). Private rooms get a 10-char invite code and the creating manager is auto-added to room_members. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>Three review fixes: - post_message in routes/room.rs no longer treats public rooms as world-writable. The handler now uses is_room_accessible (the same predicate as get_room) so a non-enclave-member - or a kicked member - cannot post to public rooms inside an enclave they do not belong to. New integration test covers this. - home.rs target_accessible for /dm/{peer_id} now requires an existing DM room via find_dm_room, so the home redirect cannot lazily create a DM with a peer the user has never messaged. - post_discover_join and post_join_by_code no-op when the caller is already a member, surfacing a redirect instead of a stray INSERT OR IGNORE write. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>load_sidebar now takes a current_enclave parameter. Home (None) returns DM peers and an empty rooms list; an enclave (Some(eid)) returns that enclave's rooms (filtered through list_rooms_in_enclave) and an empty peers list. The room handler resolves the room's enclave_id via a new enclave_for_room helper so /room/{id} pages render with the enclave's rooms in the sidebar and the matching switcher icon highlighted. The sidebar partial drops the section header when its list is empty so neither column renders an empty "Rooms" or "Direct messages" placeholder. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>WIP: feat/enclavesto feat/enclaves