package server import ( "database/sql" "net/http" ) func (s *Server) handleNotificationsPage(w http.ResponseWriter, r *http.Request) { domain := s.domainUUIDForRequest(r) principal, err := s.store.PrincipalForSession(domain, s.authTokenFromRequest(r)) if err != nil { http.Redirect(w, r, "/_/auth/login?return="+r.URL.Path, http.StatusFound) return } data := map[string]any{"Title": "Notifications", "Path": "/v/notification"} if id := r.URL.Query().Get("uuid"); id != "" { item, getErr := s.store.GetNotification(r.Context(), domain, principal.UUID, id) if getErr != nil && getErr != sql.ErrNoRows { http.Error(w, getErr.Error(), http.StatusInternalServerError) return } if getErr == nil { s.decorateTaskNotification(r, &item) data["Notification"] = item if item.Kind == "broadcast" { if broadcast, broadcastErr := s.store.GetBroadcast(r.Context(), domain, item.EventUUID); broadcastErr == nil { data["Broadcast"] = broadcast } } _ = s.store.MarkNotificationRead(domain, principal.UUID, id) } } s.renderWithContext(w, r, "notifications.gohtml", data) }