summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/api/groups.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-11 12:40:13 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-11 12:40:13 +0200
commitedde9e441fb6b84e9d56215d6e2a8d9338b8f962 (patch)
treebe09d4cc1a64e9ccc488ca9fcc1e23b6a133a8f5 /packages/meshbay-hub/src/meshbay_hub/api/groups.py
parentccb2b85051b88578c7d739ff46385e50a65591a6 (diff)
downloadmeshbay-edde9e441fb6b84e9d56215d6e2a8d9338b8f962.tar.gz
feat(hub): Phase 10.5–10.8, 10.10 — notifications, settings, search, version
- 10.5: Notification model + CRUD API (list, mark read, mark all read) Triggered on: group invite, role change, suspend/unsuspend - 10.6: SettingsPage shows role, per-group notification mute (localStorage) - 10.7: GET /v1/groups?q= search filter (ilike on name) - 10.8: NotificationFeed on home page + bell with unread badge in navbar - 10.10: GET /v1/hub/version endpoint for client update checks - 8 new tests (test_notifications.py), 155 total Co-Authored-By: Claude Opus 4.6 <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.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/api/groups.py b/packages/meshbay-hub/src/meshbay_hub/api/groups.py
index 6dd4275..a8a45c9 100644
--- a/packages/meshbay-hub/src/meshbay_hub/api/groups.py
+++ b/packages/meshbay-hub/src/meshbay_hub/api/groups.py
@@ -69,16 +69,17 @@ async def group_online_nodes(
@router.get("")
async def list_public_groups(
db: AsyncSession = Depends(get_db),
+ q: str = "",
limit: int = 50,
offset: int = 0,
include_federated: bool = True,
):
- """List public groups — local and optionally federated. No auth required."""
+ """List/search public groups — local and optionally federated. No auth required."""
+ query = select(Group).where(Group.visibility == "public", Group.status == "active")
+ if q:
+ query = query.where(Group.name.ilike(f"%{q}%"))
result = await db.execute(
- select(Group)
- .where(Group.visibility == "public", Group.status == "active")
- .order_by(Group.created_at.desc())
- .limit(limit).offset(offset)
+ query.order_by(Group.created_at.desc()).limit(limit).offset(offset)
)
local = result.scalars().all()
groups = [
@@ -90,10 +91,11 @@ async def list_public_groups(
]
if include_federated:
+ fed_query = select(FederatedGroup)
+ if q:
+ fed_query = fed_query.where(FederatedGroup.name.ilike(f"%{q}%"))
fed_result = await db.execute(
- select(FederatedGroup)
- .order_by(FederatedGroup.updated_at.desc())
- .limit(limit)
+ fed_query.order_by(FederatedGroup.updated_at.desc()).limit(limit)
)
for fg in fed_result.scalars().all():
groups.append({
@@ -217,6 +219,7 @@ async def store_gek_bundle(
# Upsert GEK bundle
existing = await db.get(GEKBundle, (group_id, target.id))
+ new_member = False
if existing:
existing.pk_eph_b64 = body.pk_eph_b64
existing.nonce_b64 = body.nonce_b64
@@ -233,6 +236,15 @@ async def store_gek_bundle(
mem = await db.get(GroupMember, (group_id, target.id))
if not mem:
db.add(GroupMember(group_id=group_id, user_id=target.id))
+ new_member = True
+
+ if new_member:
+ from meshbay_hub.api.notifications import create_notification
+ await create_notification(
+ db, target.id, "group_invite",
+ f"You were added to {group.name}",
+ link=f"#/group/{group_id}",
+ )
await db.commit()
return {"status": "stored", "group_id": group_id, "username": username}