update for mcp
This commit is contained in:
@@ -7,7 +7,12 @@ import json
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from fastapi.responses import StreamingResponse
|
||||
|
||||
from app.shared.bootstrap import get_crawl_service, get_event_store, get_perception_service
|
||||
from app.shared.bootstrap import (
|
||||
get_crawl_service,
|
||||
get_event_store,
|
||||
get_notification_store,
|
||||
get_perception_service,
|
||||
)
|
||||
from app.api.dependencies.auth import get_current_user
|
||||
from app.domain.auth.models import UserClaims
|
||||
from app.shared.async_utils import iter_in_thread
|
||||
@@ -141,3 +146,26 @@ async def get_event_diff(event_id: str):
|
||||
"previous_hash": event.get("previous_hash"),
|
||||
"content_hash": event.get("content_hash"),
|
||||
}
|
||||
|
||||
|
||||
@router.get("/notifications")
|
||||
async def list_notifications(
|
||||
limit: int = Query(default=20, ge=1, le=100),
|
||||
current_user: UserClaims = Depends(get_current_user),
|
||||
):
|
||||
"""Return the newest in-app notifications plus this user's unread count.
|
||||
|
||||
Every logged-in user sees the same broadcast feed — there is no per-role
|
||||
or per-topic subscription. "read" per item and the aggregate unread_count
|
||||
both reflect only the calling user's own read receipts.
|
||||
"""
|
||||
store = get_notification_store()
|
||||
items = store.list_for_user(current_user.user_id, limit=limit)
|
||||
return {"items": items, "unread_count": store.unread_count(current_user.user_id)}
|
||||
|
||||
|
||||
@router.post("/notifications/read")
|
||||
async def mark_notifications_read(current_user: UserClaims = Depends(get_current_user)):
|
||||
"""Mark every currently-unread notification read for the calling user."""
|
||||
marked = get_notification_store().mark_all_read(current_user.user_id)
|
||||
return {"marked": marked}
|
||||
|
||||
Reference in New Issue
Block a user