mirror of
https://github.com/hrfee/jfa-go.git
synced 2026-01-18 16:47:42 +01:00
mediabrowser: bump
imrpvoed UserNotFound error classification, no longer vulnerable to random 404s from proxies or whatever (for Jellyfin only, not emby)
This commit is contained in:
17
api-users.go
17
api-users.go
@@ -952,7 +952,7 @@ func (app *appContext) userSummary(jfUser mediabrowser.User) respUser {
|
||||
// @Success 200 {object} PageCountDTO
|
||||
// @Router /users/count [get]
|
||||
// @Security Bearer
|
||||
// @tags Activity,Statistics
|
||||
// @tags Users,Statistics
|
||||
func (app *appContext) GetUserCount(gc *gin.Context) {
|
||||
resp := PageCountDTO{}
|
||||
users, err := app.jf.GetUsers(false)
|
||||
@@ -965,6 +965,21 @@ func (app *appContext) GetUserCount(gc *gin.Context) {
|
||||
gc.JSON(200, resp)
|
||||
}
|
||||
|
||||
// @Summary Returns the list of all labels on accounts.
|
||||
// @Produce json
|
||||
// @Success 200 {object} LabelsDTO
|
||||
// @Router /users/labels [get]
|
||||
// @Security Bearer
|
||||
// @tags Users,Statistics
|
||||
func (app *appContext) GetLabels(gc *gin.Context) {
|
||||
if err := app.userCache.MaybeSync(app); err != nil {
|
||||
app.err.Printf(lm.FailedGetUsers, lm.Jellyfin, err)
|
||||
respond(500, "Couldn't get users", gc)
|
||||
return
|
||||
}
|
||||
gc.JSON(200, LabelsDTO{Labels: app.userCache.Labels})
|
||||
}
|
||||
|
||||
// @Summary Get a list of -all- Jellyfin users.
|
||||
// @Produce json
|
||||
// @Success 200 {object} getUsersDTO
|
||||
|
||||
4
go.mod
4
go.mod
@@ -20,6 +20,8 @@ replace github.com/hrfee/jfa-go/easyproxy => ./easyproxy
|
||||
|
||||
replace github.com/hrfee/jfa-go/jellyseerr => ./jellyseerr
|
||||
|
||||
// replace github.com/hrfee/mediabrowser => ../mediabrowser
|
||||
|
||||
require (
|
||||
github.com/bwmarrin/discordgo v0.29.0
|
||||
github.com/dgraph-io/badger/v4 v4.8.0
|
||||
@@ -41,7 +43,7 @@ require (
|
||||
github.com/hrfee/jfa-go/logger v0.0.0-20251123165523-7c9f91711460
|
||||
github.com/hrfee/jfa-go/logmessages v0.0.0-20251123165523-7c9f91711460
|
||||
github.com/hrfee/jfa-go/ombi v0.0.0-20251123165523-7c9f91711460
|
||||
github.com/hrfee/mediabrowser v0.3.30
|
||||
github.com/hrfee/mediabrowser v0.3.33
|
||||
github.com/itchyny/timefmt-go v0.1.7
|
||||
github.com/lithammer/shortuuid/v3 v3.0.7
|
||||
github.com/mailgun/mailgun-go/v4 v4.23.0
|
||||
|
||||
4
go.sum
4
go.sum
@@ -220,8 +220,8 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hrfee/mediabrowser v0.3.30 h1:llJo4hxWchbwROnkfhlYsrvtZ6/8WDTp3QxAvbgjUfI=
|
||||
github.com/hrfee/mediabrowser v0.3.30/go.mod h1:PnHZbdxmbv1wCVdAQyM7nwPwpVj9fdKx2EcET7sAk+U=
|
||||
github.com/hrfee/mediabrowser v0.3.33 h1:kjUFZc46hNhbOEU4xZNyhGVNjfZ5lENmX95Md1thxiA=
|
||||
github.com/hrfee/mediabrowser v0.3.33/go.mod h1:PnHZbdxmbv1wCVdAQyM7nwPwpVj9fdKx2EcET7sAk+U=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/itchyny/timefmt-go v0.1.7 h1:xyftit9Tbw+Dc/huSSPJaEmX1TVL8lw5vxjJLK4GMMA=
|
||||
github.com/itchyny/timefmt-go v0.1.7/go.mod h1:5E46Q+zj7vbTgWY8o5YkMeYb4I6GeWLFnetPy5oBrAI=
|
||||
|
||||
4
main.go
4
main.go
@@ -164,7 +164,7 @@ func test(app *appContext) {
|
||||
fmt.Println(n, ":", v)
|
||||
}
|
||||
users, err := app.jf.GetUsers(false)
|
||||
fmt.Printf("GetUsers: err %s maplength %d\n", err, len(users))
|
||||
fmt.Printf("GetUsers: err %+v maplength %d\n", err, len(users))
|
||||
fmt.Printf("View output? [y/n]: ")
|
||||
var choice string
|
||||
fmt.Scanln(&choice)
|
||||
@@ -176,7 +176,7 @@ func test(app *appContext) {
|
||||
var username string
|
||||
fmt.Scanln(&username)
|
||||
user, err := app.jf.UserByName(username, false)
|
||||
fmt.Printf("UserByName (%s): err %v", username, err)
|
||||
fmt.Printf("UserByName (%s): err %+v", username, err)
|
||||
out, _ := json.MarshalIndent(user, "", " ")
|
||||
fmt.Print(string(out))
|
||||
}
|
||||
|
||||
@@ -500,5 +500,9 @@ type TasksDTO struct {
|
||||
type TaskDTO struct {
|
||||
URL string `json:"url"`
|
||||
Name string `json:"name"`
|
||||
Description string ` json:"description"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
type LabelsDTO struct {
|
||||
Labels []string `json:'labels"`
|
||||
}
|
||||
|
||||
@@ -202,6 +202,7 @@ func (app *appContext) loadRoutes(router *gin.Engine) {
|
||||
api.GET(p+"/users/count", app.GetUserCount)
|
||||
api.POST(p+"/users", app.SearchUsers)
|
||||
api.POST(p+"/users/count", app.GetFilteredUserCount)
|
||||
api.GET(p+"/users/labels", app.GetLabels)
|
||||
api.POST(p+"/user", app.NewUserFromAdmin)
|
||||
api.POST(p+"/users/extend", app.ExtendExpiry)
|
||||
api.DELETE(p+"/users/:id/expiry", app.RemoveExpiry)
|
||||
|
||||
@@ -2195,6 +2195,7 @@ export class accountsList extends PaginatedList {
|
||||
// An alternate view showing accounts in sub-lists grouped by group/label.
|
||||
export class groupedAccountsList {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
10
usercache.go
10
usercache.go
@@ -46,6 +46,7 @@ type UserCache struct {
|
||||
Syncing bool
|
||||
SortLock sync.Mutex
|
||||
Sorting bool
|
||||
Labels []string
|
||||
}
|
||||
|
||||
func NewUserCache(syncTimeout, waitForSyncTimeout time.Duration) *UserCache {
|
||||
@@ -85,16 +86,25 @@ func (c *UserCache) MaybeSync(app *appContext) error {
|
||||
return
|
||||
}
|
||||
cache := make([]respUser, len(users))
|
||||
labels := map[string]bool{}
|
||||
for i, jfUser := range users {
|
||||
cache[i] = app.userSummary(jfUser)
|
||||
if cache[i].Label != "" {
|
||||
labels[cache[i].Label] = true
|
||||
}
|
||||
}
|
||||
ref := make([]*respUser, len(cache))
|
||||
for i := range cache {
|
||||
ref[i] = &(cache[i])
|
||||
}
|
||||
labelSlice := make([]string, 0, len(labels))
|
||||
for label, _ := range labels {
|
||||
labelSlice = append(labelSlice, label)
|
||||
}
|
||||
c.Cache = cache
|
||||
c.Ref = ref
|
||||
c.Sorted = false
|
||||
c.Labels = labelSlice
|
||||
c.LastSync = time.Now()
|
||||
|
||||
c.SyncLock.Lock()
|
||||
|
||||
Reference in New Issue
Block a user