2023-08-16 15:49:46 -07:00
|
|
|
package user
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"codeberg.org/pronounscc/pronouns.cc/backend/log"
|
|
|
|
"codeberg.org/pronounscc/pronouns.cc/backend/server"
|
2023-09-19 17:39:14 -07:00
|
|
|
"emperror.dev/errors"
|
2023-08-16 15:49:46 -07: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-19 17:39:14 -07:00
|
|
|
return errors.Wrap(err, "getting user")
|
2023-08-16 15:49:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
render.JSON(w, r, u.Settings)
|
|
|
|
return nil
|
|
|
|
}
|