rework voice_rooms api
This commit is contained in:
@ -19,12 +19,12 @@ def _serialize(doc):
|
||||
|
||||
class VoiceRoomService:
|
||||
|
||||
async def list_public_rooms(self):
|
||||
rooms = await voice_rooms_collection.find(
|
||||
{"public": True}
|
||||
).sort("created_at", -1).to_list(100)
|
||||
async def list_rooms(self):
|
||||
rooms = await voice_rooms_collection.find({}) \
|
||||
.sort("created_at", -1) \
|
||||
.to_list(100)
|
||||
|
||||
return [_serialize(r) for r in rooms]
|
||||
return rooms
|
||||
|
||||
async def create_room(
|
||||
self,
|
||||
@ -64,4 +64,10 @@ class VoiceRoomService:
|
||||
room = await voice_rooms_collection.find_one({"invite_code": code})
|
||||
if not room:
|
||||
raise HTTPException(404, "Invalid invite code")
|
||||
return _serialize(room)
|
||||
|
||||
return {
|
||||
"id": room["id"],
|
||||
"name": room["name"],
|
||||
"public": False,
|
||||
"max_users": room.get("max_users"),
|
||||
}
|
||||
Reference in New Issue
Block a user