mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-23 01:20:11 +00:00
disallow negative values in ExtendExpiry, fix nil map err
This commit is contained in:
parent
afedc78113
commit
8a6cfe0b4d
8
api.go
8
api.go
@ -471,7 +471,7 @@ func (app *appContext) ExtendExpiry(gc *gin.Context) {
|
|||||||
var req extendExpiryDTO
|
var req extendExpiryDTO
|
||||||
gc.BindJSON(&req)
|
gc.BindJSON(&req)
|
||||||
app.info.Printf("Expiry extension requested for %d user(s)", len(req.Users))
|
app.info.Printf("Expiry extension requested for %d user(s)", len(req.Users))
|
||||||
if req.Days == 0 && req.Hours == 0 && req.Minutes == 0 {
|
if req.Days <= 0 && req.Hours <= 0 && req.Minutes <= 0 {
|
||||||
respondBool(400, false, gc)
|
respondBool(400, false, gc)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1024,13 +1024,14 @@ func (app *appContext) DeleteInvite(gc *gin.Context) {
|
|||||||
func (app *appContext) GetUsers(gc *gin.Context) {
|
func (app *appContext) GetUsers(gc *gin.Context) {
|
||||||
app.debug.Println("Users requested")
|
app.debug.Println("Users requested")
|
||||||
var resp getUsersDTO
|
var resp getUsersDTO
|
||||||
resp.UserList = []respUser{}
|
|
||||||
users, status, err := app.jf.GetUsers(false)
|
users, status, err := app.jf.GetUsers(false)
|
||||||
|
resp.UserList = make([]respUser, len(users))
|
||||||
if !(status == 200 || status == 204) || err != nil {
|
if !(status == 200 || status == 204) || err != nil {
|
||||||
app.err.Printf("Failed to get users from Jellyfin (%d): %v", status, err)
|
app.err.Printf("Failed to get users from Jellyfin (%d): %v", status, err)
|
||||||
respond(500, "Couldn't get users", gc)
|
respond(500, "Couldn't get users", gc)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
i := 0
|
||||||
for _, jfUser := range users {
|
for _, jfUser := range users {
|
||||||
user := respUser{
|
user := respUser{
|
||||||
ID: jfUser.ID,
|
ID: jfUser.ID,
|
||||||
@ -1049,7 +1050,8 @@ func (app *appContext) GetUsers(gc *gin.Context) {
|
|||||||
user.Expiry = app.formatDatetime(expiry)
|
user.Expiry = app.formatDatetime(expiry)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.UserList = append(resp.UserList, user)
|
resp.UserList[i] = user
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
gc.JSON(200, resp)
|
gc.JSON(200, resp)
|
||||||
}
|
}
|
||||||
|
@ -480,6 +480,9 @@ func (st *Storage) storeInvites() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (st *Storage) loadUsers() error {
|
func (st *Storage) loadUsers() error {
|
||||||
|
if st.users == nil {
|
||||||
|
st.users = map[string]time.Time{}
|
||||||
|
}
|
||||||
st.usersLock.Lock()
|
st.usersLock.Lock()
|
||||||
defer st.usersLock.Unlock()
|
defer st.usersLock.Unlock()
|
||||||
temp := map[string]time.Time{}
|
temp := map[string]time.Time{}
|
||||||
|
Loading…
Reference in New Issue
Block a user