2023-08-17 00:49:46 +02:00
|
|
|
package user
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"codeberg.org/pronounscc/pronouns.cc/backend/log"
|
|
|
|
"codeberg.org/pronounscc/pronouns.cc/backend/server"
|
2023-09-20 02:39:14 +02:00
|
|
|
"emperror.dev/errors"
|
2023-08-17 00:49:46 +02:00
|
|
|
"github.com/go-chi/render"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *Server) GetSettings(w http.ResponseWriter, r *http.Request) (err error) {
|
|
|
|
claims, _ := server.ClaimsFromContext(r.Context())
|
|
|
|
u, err := s.DB.User(r.Context(), claims.UserID)
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("getting user: %v", err)
|
2023-09-20 02:39:14 +02:00
|
|
|
return errors.Wrap(err, "getting user")
|
2023-08-17 00:49:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render.JSON(w, r, u.Settings)
|
|
|
|
return nil
|
|
|
|
}
|