aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/api/admin.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-28 10:09:38 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-28 10:09:38 +0200
commit58ca879b017da62e77f40752d8d94fef3f315a1e (patch)
tree38cb9b1f8007009e39b462bcda16830aa2b0ede3 /packages/meshbay-hub/src/meshbay_hub/api/admin.py
parent471fa6242fc56a035a8c9639722a82b9341328c2 (diff)
downloadmeshbay-58ca879b017da62e77f40752d8d94fef3f315a1e.tar.gz
feat(hub): group names unique per owner, shown as name@owner
A group's identity stays its UUID. What changes is that "the name is unique" — until now an unenforced expectation — becomes real, scoped to the owner account, and the owner's username is surfaced so two groups called "photos" on different nodes can be told apart. Hub: - `groups` gains a functional unique index `uq_groups_owner_name` on `(admin_id, lower(name))` (model + migration c3d4e5f6a7b8). The migration pre-flights: if the data already clashes it aborts and lists the offending (admin_id, name) pairs rather than renaming anyone's group. meshbay.org checked clean. - `create_group` trims the name, rejects blank (422) and an owner-scoped case-insensitive clash (409), with an IntegrityError backstop for the race, and returns `owner_username`. - `owner_username` added to `/v1/groups/mine`, `GET /v1/groups` (local rows), `POST /v1/groups/{id}/join`, `GET /v1/admin/groups`. SPA: - new `static/group-name.js` — `<GroupName name owner [inline]>` renders the name with the `@owner` handle on a smaller grey line under it. - used in the sidebar, the group-page header, Explore cards, the Admin groups table, and cross-group Search (via a widened `cacheGroupIndex` carrying the owner). Delete/leave confirmations show `name@owner` inline. - federated Explore rows show `@<source_hub>` instead of an account. Design record and the locked decisions: ~/next/groupnames.md (out of repo). MNP unchanged. Tests: test_group_name_unique.py, test_group_name_migration.py. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018gKJ85aZyvEwarXMFzFEwi
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/api/admin.py')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/api/admin.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/api/admin.py b/packages/meshbay-hub/src/meshbay_hub/api/admin.py
index 4141c79..ab6fa07 100644
--- a/packages/meshbay-hub/src/meshbay_hub/api/admin.py
+++ b/packages/meshbay-hub/src/meshbay_hub/api/admin.py
@@ -301,12 +301,18 @@ async def admin_list_groups(
total = (await db.execute(select(func.count()).select_from(Group))).scalar_one()
+ owner_ids = {g.admin_id for g, _ in rows}
+ owner_by_id = dict((await db.execute(
+ select(User.id, User.username).where(User.id.in_(owner_ids)))).all()) \
+ if owner_ids else {}
+
return {
"groups": [
{
"id": g.id,
"name": g.name,
"admin_id": g.admin_id,
+ "owner_username": owner_by_id.get(g.admin_id),
"visibility": g.visibility,
"description": g.description or "",
"status": g.status,