diff options
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/api/groups.py')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/api/groups.py | 29 |
1 files changed, 29 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 942a88e..0092fbd 100644 --- a/packages/meshbay-hub/src/meshbay_hub/api/groups.py +++ b/packages/meshbay-hub/src/meshbay_hub/api/groups.py @@ -12,6 +12,35 @@ from meshbay_hub.db.models import GEKBundle, Group, GroupMember, IPLog, User router = APIRouter(prefix="/v1/groups", tags=["groups"]) +@router.get("") +async def list_public_groups( + db: AsyncSession = Depends(get_db), + limit: int = 50, + offset: int = 0, +): + """List public groups — browsable without authentication.""" + result = await db.execute( + select(Group) + .where(Group.visibility == "public", Group.status == "active") + .order_by(Group.created_at.desc()) + .limit(limit) + .offset(offset) + ) + groups = result.scalars().all() + return { + "groups": [ + { + "id": g.id, + "name": g.name, + "join_policy": g.join_policy, + "created_at": g.created_at.isoformat(), + } + for g in groups + ], + "total": len(groups), + } + + class GroupCreateRequest(BaseModel): name: str visibility: str = "private" # public|private |