diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-08-15 02:34:19 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-08-15 02:34:19 +0200 |
| commit | 84b032c65e17267d41e04605e79eea82a6f5a59f (patch) | |
| tree | eb7708a72944bb15540e103b4319242199af6fbb /packages/meshbay-hub/src/meshbay_hub/api/groups.py | |
| parent | 5338894f7fec9e1a60affb0e2ff3b9797bcbc968 (diff) | |
| download | meshbay-84b032c65e17267d41e04605e79eea82a6f5a59f.tar.gz | |
feat(groups): editable description, and one source of operator authority
A description could only be set the moment a group was created, so every
group made before anyone thought of one stayed blank for good. The owner
can now edit it from the group's page, and PATCH /v1/groups/{id} takes it.
That endpoint takes the description and nothing else, deliberately. The
name, the visibility and the join policy are the terms members joined on;
a private group that can quietly become public is not the group they
agreed to be in. Changing those needs a decision about who gets told, not
a field on a form — there is a test saying so.
Separately, the legacy operator key is gone. `admin_pk_ed25519` in
node.toml named the operator before the roster existed and was kept so
that an existing deployment would keep working; nothing uses it, and a
second source of node authority is not something to carry around out of
politeness. Authority is the roster, read fresh on every check.
It is removed rather than ignored: a config that still names the key gets
a warning at startup pointing at the file. Dropping it in silence would
refuse invites and file deletion with a signature error that looks like a
bug somewhere else — which is exactly how finding M3 presented.
Two tests were verifying admin operations by naming a key in the context,
which was the legacy path. They now pair an operator into a roster, the
way an operator does. The authority test anchored on the deleted function
and passed vacuously once it disappeared; it states the invariant against
the verifier and the daemon instead.
Also defined .btn-secondary, used in four places and styled in none.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/api/groups.py')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/api/groups.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/api/groups.py b/packages/meshbay-hub/src/meshbay_hub/api/groups.py index 43d72c3..83feeb4 100644 --- a/packages/meshbay-hub/src/meshbay_hub/api/groups.py +++ b/packages/meshbay-hub/src/meshbay_hub/api/groups.py @@ -276,6 +276,38 @@ async def create_group( return {"group_id": group.id, "name": group.name} +class GroupUpdateRequest(BaseModel): + description: str | None = None + + +@router.patch("/{group_id}") +async def update_group( + group_id: str, + body: GroupUpdateRequest, + current_user: User = Depends(require_user_scope), + db: AsyncSession = Depends(get_db), +): + """ + Change the group's description. Owner only. + + Only the description: name, visibility and join policy are what members + joined on the strength of, and a group that can quietly become public is a + different thing from the one they agreed to. Those need a decision about who + is told, not a PATCH. + """ + group = await db.get(Group, group_id) + if not group: + raise HTTPException(status_code=404, detail="Group not found") + if group.admin_id != current_user.id: + raise HTTPException(status_code=403, detail="Only the group owner can edit it") + + if body.description is not None: + desc = body.description.strip()[:512] + group.description = desc or None + await db.commit() + return {"group_id": group.id, "description": group.description or ""} + + @router.post("/{group_id}/members/{username}", status_code=201) async def add_group_member( group_id: str, |