Files
Agent-System/internal/server/notification_handlers.go
T
weichenandCursor f6813cc272 feat(api): add additive HTTP/SSE error envelopes
Public errors now emit code, safe message, and request_id while keeping the legacy error field. Raw SQL, paths, tokens, and XSS payloads are stripped; the frontend branches on code instead of substring matching.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-15 14:40:56 +00:00

36 lines
975 B
Go

package server
import (
"net/http"
"strconv"
)
func (s *Server) handleListProjectNotifications(w http.ResponseWriter, r *http.Request) {
user, ok := s.requireAuthenticatedUser(w, r)
if !ok {
return
}
if s.notifySvc == nil || !s.notifySvc.Available() {
writeSafeError(w, r, http.StatusServiceUnavailable, "notification service unavailable")
return
}
projectID, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
if err != nil || projectID <= 0 {
writeSafeError(w, r, http.StatusBadRequest, "invalid project id")
return
}
sinceID, _ := strconv.ParseInt(r.URL.Query().Get("since_id"), 10, 64)
limit, _ := strconv.Atoi(r.URL.Query().Get("limit"))
items, err := s.notifySvc.ListProjectNotifications(r.Context(), user.ID, projectID, sinceID, limit)
if err != nil {
writeSafeError(w, r, http.StatusInternalServerError, "list notifications failed: "+err.Error())
return
}
writeJSONResponse(w, http.StatusOK, map[string]any{
"items": items,
})
}