api-users: add individual user summary route

GET /users/:id, skips the usercache.
This commit is contained in:
Harvey Tindall
2025-12-21 19:19:46 +00:00
parent e2c34e574d
commit 41334e9051
2 changed files with 32 additions and 0 deletions

View File

@@ -1022,6 +1022,37 @@ func (app *appContext) GetLabels(gc *gin.Context) {
gc.JSON(200, LabelsDTO{Labels: app.userCache.Labels}) 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. // @Summary Get a list of -all- Jellyfin users.
// @Produce json // @Produce json
// @Success 200 {object} getUsersDTO // @Success 200 {object} getUsersDTO

View File

@@ -206,6 +206,7 @@ func (app *appContext) loadRoutes(router *gin.Engine) {
api.POST(p+"/user", app.NewUserFromAdmin) api.POST(p+"/user", app.NewUserFromAdmin)
api.POST(p+"/users/extend", app.ExtendExpiry) api.POST(p+"/users/extend", app.ExtendExpiry)
api.DELETE(p+"/users/:id/expiry", app.RemoveExpiry) 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", app.GetJFActivitesForUser)
api.GET(p+"/users/:id/activities/jellyfin/count", app.CountJFActivitesForUser) api.GET(p+"/users/:id/activities/jellyfin/count", app.CountJFActivitesForUser)
api.POST(p+"/users/:id/activities/jellyfin", app.GetPaginatedJFActivitesForUser) api.POST(p+"/users/:id/activities/jellyfin", app.GetPaginatedJFActivitesForUser)