aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/api/groups.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-11 04:13:53 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-11 04:13:53 +0200
commite23e33adeaf8ee7439187d4451c856b37816a51f (patch)
treea41eef1fba34cdd642d25576395b4ad484a748ad /packages/meshbay-hub/src/meshbay_hub/api/groups.py
parent60c4570e72e36c2a9720593c8baec74ee2ab52d6 (diff)
downloadmeshbay-e23e33adeaf8ee7439187d4451c856b37816a51f.tar.gz
feat: Phase 9 — Web client SPA with WebRTC P2P transport
Complete browser-based client: Preact SPA with login, group file browser, encrypted download, video playback, group chat, i18n, and dark/light theme. Browser connects P2P to nodes behind residential NAT via WebRTC DataChannel (aiortc). Hub handles signaling only — all data flows E2E. Performance: pipelined downloads (8-chunk sliding window), binary msgpack wire format (no base64), redundant I/O elimination. Large file downloads stream to disk via File System Access API (showSaveFilePicker). Validated on SFR + Orange residential NATs, Chrome + Firefox, IPv4/IPv6. 132 tests passing. Deployed to meshbay.org + Orange node. 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.py51
1 files changed, 51 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 5bccf71..6dd4275 100644
--- a/packages/meshbay-hub/src/meshbay_hub/api/groups.py
+++ b/packages/meshbay-hub/src/meshbay_hub/api/groups.py
@@ -15,6 +15,57 @@ from meshbay_hub.db.models import (
router = APIRouter(prefix="/v1/groups", tags=["groups"])
+@router.get("/mine")
+async def my_groups(
+ current_user: User = Depends(get_current_user),
+ db: AsyncSession = Depends(get_db),
+):
+ """List groups the current user belongs to."""
+ result = await db.execute(
+ select(Group)
+ .join(GroupMember, Group.id == GroupMember.group_id)
+ .where(GroupMember.user_id == current_user.id, Group.status == "active")
+ .order_by(Group.name)
+ )
+ groups = result.scalars().all()
+ return {
+ "groups": [
+ {
+ "id": g.id,
+ "name": g.name,
+ "visibility": g.visibility,
+ "join_policy": g.join_policy,
+ "created_at": g.created_at.isoformat(),
+ "is_admin": g.admin_id == current_user.id,
+ }
+ for g in groups
+ ]
+ }
+
+
+@router.get("/{group_id}/nodes")
+async def group_online_nodes(
+ group_id: str,
+ current_user: User = Depends(get_current_user),
+ db: AsyncSession = Depends(get_db),
+):
+ """Return online nodes that serve a group (for WebRTC connection)."""
+ from meshbay_hub.api.revocation import get_online_nodes_for_group
+ from meshbay_hub.db.models import Node
+
+ group = await db.get(Group, group_id)
+ if not group:
+ raise HTTPException(status_code=404, detail="Group not found")
+
+ node_ids = get_online_nodes_for_group(group_id)
+ nodes = []
+ for nid in node_ids:
+ node = await db.get(Node, nid)
+ if node:
+ nodes.append({"node_id": nid, "pk_node": node.pk_node})
+ return {"nodes": nodes}
+
+
@router.get("")
async def list_public_groups(
db: AsyncSession = Depends(get_db),