2026-10-15 18:34:53 -07:00
|
|
|
package server
|
|
|
|
|
|
|
|
|
|
import (
|
2026-10-18 00:57:51 -07:00
|
|
|
"errors"
|
2026-10-15 18:34:53 -07:00
|
|
|
"net/http"
|
2026-10-18 00:57:51 -07:00
|
|
|
"strings"
|
2026-10-15 18:34:53 -07:00
|
|
|
|
2026-10-18 15:32:07 -07:00
|
|
|
"g.fc.run/ai/byre/internal/api"
|
2026-10-15 18:34:53 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func (s *Server) UpdateNotificationPrefs(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
req := api.NotificationPrefs{}
|
|
|
|
|
if !readJSON(w, r, &req) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
u, err := s.store.UpdateNotificationPrefs(r.Context(), actor(r), req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
writeStoreError(w, err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
writeJSON(w, http.StatusOK, u)
|
|
|
|
|
}
|
2026-10-18 00:57:51 -07:00
|
|
|
|
|
|
|
|
func (s *Server) UpdateDefaultModel(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
req := api.DefaultModel{}
|
|
|
|
|
if !readJSON(w, r, &req) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if strings.TrimSpace(req.Model) == "" {
|
|
|
|
|
writeError(w, http.StatusBadRequest, errors.New("model is required"))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
u, err := s.store.UpdateDefaultModel(r.Context(), actor(r), req.Model)
|
|
|
|
|
if err != nil {
|
|
|
|
|
writeStoreError(w, err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
writeJSON(w, http.StatusOK, u)
|
|
|
|
|
}
|