mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-16 05:17:55 -04:00
add skel for photos
Signed-off-by: Christian Richter <c.richter@opencloud.eu>
This commit is contained in:
committed by
Florian Schade
parent
b954681c3b
commit
e23b8f412b
56
services/graph/pkg/service/v0/photo.go
Normal file
56
services/graph/pkg/service/v0/photo.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
"github.com/go-chi/render"
|
||||
"github.com/opencloud-eu/opencloud/services/graph/pkg/errorcode"
|
||||
revactx "github.com/opencloud-eu/reva/v2/pkg/ctx"
|
||||
)
|
||||
|
||||
// GetMePhoto implements the Service interface
|
||||
func (g Graph) GetMePhoto(w http.ResponseWriter, r *http.Request) {
|
||||
logger := g.logger.SubloggerWithRequestID(r.Context())
|
||||
logger.Debug().Msg("GetMePhoto called")
|
||||
u, ok := revactx.ContextGetUser(r.Context())
|
||||
if !ok {
|
||||
logger.Debug().Msg("could not get user: user not in context")
|
||||
errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, "user not in context")
|
||||
return
|
||||
}
|
||||
g.GetPhoto(w, r, u.GetId())
|
||||
}
|
||||
|
||||
// GetPhoto implements the Service interface
|
||||
func (g Graph) GetPhoto(w http.ResponseWriter, r *http.Request, u *userpb.UserId) {
|
||||
logger := g.logger.SubloggerWithRequestID(r.Context())
|
||||
logger.Debug().Msg("GetPhoto called")
|
||||
|
||||
// TODO: use proper default return
|
||||
render.Status(r, http.StatusNotFound)
|
||||
render.JSON(w, r, nil)
|
||||
}
|
||||
|
||||
// UpdateMePhoto implements the Service interface
|
||||
func (g Graph) UpdateMePhoto(w http.ResponseWriter, r *http.Request) {
|
||||
logger := g.logger.SubloggerWithRequestID(r.Context())
|
||||
logger.Debug().Msg("UpdateMePhoto called")
|
||||
u, ok := revactx.ContextGetUser(r.Context())
|
||||
if !ok {
|
||||
logger.Debug().Msg("could not get user: user not in context")
|
||||
errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, "user not in context")
|
||||
return
|
||||
}
|
||||
g.UpdatePhoto(w, r, u.GetId())
|
||||
}
|
||||
|
||||
// UpdatePhoto implements the Service interface
|
||||
func (g Graph) UpdatePhoto(w http.ResponseWriter, r *http.Request, u *userpb.UserId) {
|
||||
logger := g.logger.SubloggerWithRequestID(r.Context())
|
||||
logger.Debug().Msg("UpdatePhoto called")
|
||||
|
||||
// TODO: use proper default return
|
||||
render.Status(r, http.StatusForbidden)
|
||||
render.JSON(w, r, nil)
|
||||
}
|
||||
@@ -293,6 +293,8 @@ func NewService(opts ...Option) (Graph, error) { //nolint:maintidx
|
||||
})
|
||||
r.Get("/drives", svc.GetDrives(APIVersion_1))
|
||||
r.Post("/changePassword", svc.ChangeOwnPassword)
|
||||
r.Get("/photo", svc.GetMePhoto)
|
||||
r.Put("/photo", svc.UpdateMePhoto)
|
||||
})
|
||||
r.Route("/users", func(r chi.Router) {
|
||||
r.Get("/", svc.GetUsers)
|
||||
|
||||
Reference in New Issue
Block a user