mirror of
https://github.com/hrfee/jfa-go.git
synced 2026-03-18 21:50:33 +01:00
api-users: add individual user summary route
GET /users/:id, skips the usercache.
This commit is contained in:
31
api-users.go
31
api-users.go
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user