feat: public guest room discovery endpoints (slice 1 for webapp #141)
GET /public/rooms + /public/rooms/{id} — no auth, active rooms only,
operator-private fields stripped. The webapp guest UI needs these because
the existing GET /rooms is admin-scoped; availability + booking POST are
already public. Reuses the public_room_dict strip.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019VUQCfdqiLSsFS2jcGnaFD
This commit is contained in:
parent
4d6dba5487
commit
0631edf8a2
1 changed files with 22 additions and 0 deletions
22
views_api.py
22
views_api.py
|
|
@ -24,6 +24,7 @@ from .models import (
|
||||||
CreateRoomData,
|
CreateRoomData,
|
||||||
Room,
|
Room,
|
||||||
RoomStatus,
|
RoomStatus,
|
||||||
|
public_room_dict,
|
||||||
)
|
)
|
||||||
from .nostr import service as nostr
|
from .nostr import service as nostr
|
||||||
|
|
||||||
|
|
@ -189,6 +190,27 @@ async def api_update_settings(
|
||||||
return await crud.update_settings(settings)
|
return await crud.update_settings(settings)
|
||||||
|
|
||||||
|
|
||||||
|
# --- public guest discovery (no auth) --------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@chatelet_api_router.get("/api/v1/public/rooms")
|
||||||
|
async def api_public_rooms() -> list[dict]:
|
||||||
|
"""Active rooms for guest browsing — operator-private fields stripped."""
|
||||||
|
return [
|
||||||
|
public_room_dict(r)
|
||||||
|
for r in await crud.get_rooms()
|
||||||
|
if r.status == RoomStatus.active
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@chatelet_api_router.get("/api/v1/public/rooms/{room_id}")
|
||||||
|
async def api_public_room(room_id: str) -> dict:
|
||||||
|
room = await crud.get_room(room_id)
|
||||||
|
if not room or room.status != RoomStatus.active:
|
||||||
|
raise HTTPException(404, "Room not available")
|
||||||
|
return public_room_dict(room)
|
||||||
|
|
||||||
|
|
||||||
# --- availability (public read) --------------------------------------------
|
# --- availability (public read) --------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue