Private
Public Access
Backend: PushSubscription model/migration, VAPID config + `cli.py generate-vapid-keys`, push_service.send_push_to_user (upsert-by-endpoint subscribe/unsubscribe, auto-cleanup of expired 404/410 subscriptions), /api/push/* router, and ConnectionManager now tracks connected user IDs per room so chat.py can push only to offline members after broadcasting to online ones. Two test-infra bugs found and fixed along the way: send_push_to_user takes the caller's AsyncSession and is awaited inline rather than fired via asyncio.create_task with its own session (background tasks were outliving the test event loop); and the ws_client fixture now uses NullPool to eliminate a connection-pool checkout race that was failing WS tests intermittently. Frontend: service worker rebuilt with vite-plugin-pwa's injectManifest strategy (custom src/sw.ts) so it can add push/notificationclick handlers alongside the existing precaching and StaleWhileRevalidate routes ported over from generateSW. New subscribe/unsubscribe flow (lib/push.ts, api/push.ts) with a toggle in the account menu. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
34 lines
891 B
Python
34 lines
891 B
Python
from fastapi import FastAPI
|
|
from starlette.middleware.sessions import SessionMiddleware
|
|
|
|
from app.config import settings
|
|
from app.routers import auth, health, invites, push, rooms
|
|
from app.ws.chat import router as ws_router
|
|
from app.ws.connection_manager import ConnectionManager
|
|
|
|
|
|
def create_app() -> FastAPI:
|
|
app = FastAPI(title="KeepItTalking")
|
|
|
|
app.add_middleware(
|
|
SessionMiddleware,
|
|
secret_key=settings.session_secret,
|
|
same_site="lax",
|
|
https_only=settings.session_https_only,
|
|
max_age=settings.session_max_age_seconds,
|
|
)
|
|
|
|
app.state.connection_manager = ConnectionManager()
|
|
|
|
app.include_router(health.router)
|
|
app.include_router(auth.router)
|
|
app.include_router(rooms.router)
|
|
app.include_router(invites.router)
|
|
app.include_router(push.router)
|
|
app.include_router(ws_router)
|
|
|
|
return app
|
|
|
|
|
|
app = create_app()
|