59014f6fe7
Full implementations replacing stubs: speakers CRUD with utterance count, rooms list + mute/unmute via pipeline, FTS5-based search, RAG /ask and /summary endpoints. 15 route tests (8 new) all passing; 35 total. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
import sqlite3
|
|
import httpx
|
|
from fastapi import APIRouter, HTTPException
|
|
from app.shared.config import Settings
|
|
|
|
|
|
def make_router(settings: Settings, db_factory):
|
|
router = APIRouter(prefix="/api/rooms")
|
|
|
|
@router.get("")
|
|
def list_rooms():
|
|
db: sqlite3.Connection = db_factory()
|
|
rows = db.execute(
|
|
"SELECT id, name, device_label, is_active, last_seen, created_at FROM rooms ORDER BY name"
|
|
).fetchall()
|
|
return [dict(r) for r in rows]
|
|
|
|
@router.post("/{room_id}/mute")
|
|
def mute_room(room_id: int):
|
|
db: sqlite3.Connection = db_factory()
|
|
row = db.execute("SELECT name FROM rooms WHERE id=?", (room_id,)).fetchone()
|
|
if not row:
|
|
raise HTTPException(404, "Room not found")
|
|
httpx.post(f"{settings.pipeline_internal_url}/internal/rooms/{row['name']}/mute")
|
|
return {"ok": True, "room": row["name"]}
|
|
|
|
@router.post("/{room_id}/unmute")
|
|
def unmute_room(room_id: int):
|
|
db: sqlite3.Connection = db_factory()
|
|
row = db.execute("SELECT name FROM rooms WHERE id=?", (room_id,)).fetchone()
|
|
if not row:
|
|
raise HTTPException(404, "Room not found")
|
|
httpx.post(f"{settings.pipeline_internal_url}/internal/rooms/{row['name']}/unmute")
|
|
return {"ok": True, "room": row["name"]}
|
|
|
|
return router
|