diff --git a/api-users.go b/api-users.go index afab1cb..3a1592c 100644 --- a/api-users.go +++ b/api-users.go @@ -1022,6 +1022,37 @@ func (app *appContext) GetLabels(gc *gin.Context) { gc.JSON(200, LabelsDTO{Labels: app.userCache.Labels}) } +// @Summary Get the details of a given user. Skips the user cache and gets fresh information. +// @Produce json +// @Success 200 {object} respUser +// @Failure 400 {object} boolResponse +// @Failure 500 {object} stringResponse +// @Param id path string true "id of user to fetch details of" +// @Router /users/{id} [get] +// @Security Bearer +// @tags Users +func (app *appContext) GetUser(gc *gin.Context) { + userID := gc.Param("id") + if userID == "" { + respondBool(400, false, gc) + return + } + user, err := app.jf.UserByID(userID, false) + if err != nil { + switch err.(type) { + case mediabrowser.ErrUserNotFound: + respondBool(400, false, gc) + app.err.Printf(lm.FailedGetUser, userID, lm.Jellyfin, err) + return + default: + respond(500, "Check logs", gc) + app.err.Printf(lm.FailedGetUser, userID, lm.Jellyfin, err) + return + } + } + gc.JSON(200, app.GetUserSummary(user)) +} + // @Summary Get a list of -all- Jellyfin users. // @Produce json // @Success 200 {object} getUsersDTO diff --git a/router.go b/router.go index f4c187b..a5fbdc2 100644 --- a/router.go +++ b/router.go @@ -206,6 +206,7 @@ func (app *appContext) loadRoutes(router *gin.Engine) { api.POST(p+"/user", app.NewUserFromAdmin) api.POST(p+"/users/extend", app.ExtendExpiry) api.DELETE(p+"/users/:id/expiry", app.RemoveExpiry) + api.GET(p+"/users/:id", app.GetUser) api.GET(p+"/users/:id/activities/jellyfin", app.GetJFActivitesForUser) api.GET(p+"/users/:id/activities/jellyfin/count", app.CountJFActivitesForUser) api.POST(p+"/users/:id/activities/jellyfin", app.GetPaginatedJFActivitesForUser)