mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-23 01:20:11 +00:00
add comments, fix user expiry log spam
now actually removes the already deleted user from the expiry list.
This commit is contained in:
parent
e351c35cc8
commit
1a6d78352c
2
main.go
2
main.go
@ -79,7 +79,7 @@ type appContext struct {
|
|||||||
configBase settings
|
configBase settings
|
||||||
dataPath string
|
dataPath string
|
||||||
webFS httpFS
|
webFS httpFS
|
||||||
cssClass string
|
cssClass string // Default theme, "light-theme"|"dark-theme".
|
||||||
jellyfinLogin bool
|
jellyfinLogin bool
|
||||||
users []User
|
users []User
|
||||||
invalidTokens []string
|
invalidTokens []string
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Mediabrowser provides user-related bindings to the Jellyfin & Emby APIs.
|
||||||
|
// Some data aren't bound to structs as jfa-go doesn't need to interact with them, for example DisplayPreferences.
|
||||||
|
// See Jellyfin/Emby swagger docs for more info on them.
|
||||||
package mediabrowser
|
package mediabrowser
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -21,7 +24,8 @@ const (
|
|||||||
EmbyServer
|
EmbyServer
|
||||||
)
|
)
|
||||||
|
|
||||||
type serverInfo struct {
|
// ServerInfo stores info about the server.
|
||||||
|
type ServerInfo struct {
|
||||||
LocalAddress string `json:"LocalAddress"`
|
LocalAddress string `json:"LocalAddress"`
|
||||||
Name string `json:"ServerName"`
|
Name string `json:"ServerName"`
|
||||||
Version string `json:"Version"`
|
Version string `json:"Version"`
|
||||||
@ -39,7 +43,7 @@ type MediaBrowser struct {
|
|||||||
useragent string
|
useragent string
|
||||||
auth string
|
auth string
|
||||||
header map[string]string
|
header map[string]string
|
||||||
ServerInfo serverInfo
|
ServerInfo ServerInfo
|
||||||
Username string
|
Username string
|
||||||
password string
|
password string
|
||||||
Authenticated bool
|
Authenticated bool
|
||||||
@ -56,7 +60,7 @@ type MediaBrowser struct {
|
|||||||
timeoutHandler common.TimeoutHandler
|
timeoutHandler common.TimeoutHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServer returns a new Jellyfin object.
|
// NewServer returns a new Mediabrowser object.
|
||||||
func NewServer(st serverType, server, client, version, device, deviceID string, timeoutHandler common.TimeoutHandler, cacheTimeout int) (*MediaBrowser, error) {
|
func NewServer(st serverType, server, client, version, device, deviceID string, timeoutHandler common.TimeoutHandler, cacheTimeout int) (*MediaBrowser, error) {
|
||||||
mb := &MediaBrowser{}
|
mb := &MediaBrowser{}
|
||||||
mb.serverType = st
|
mb.serverType = st
|
||||||
|
@ -11,6 +11,7 @@ type magicParse struct {
|
|||||||
Parsed time.Time `json:"parseme"`
|
Parsed time.Time `json:"parseme"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Time embeds time.Time with a custom JSON Unmarshal method to work with Jellyfin & Emby's time formatting.
|
||||||
type Time struct {
|
type Time struct {
|
||||||
time.Time
|
time.Time
|
||||||
}
|
}
|
||||||
@ -62,6 +63,7 @@ type User struct {
|
|||||||
LastLoginDate Time `json:"LastLoginDate"`
|
LastLoginDate Time `json:"LastLoginDate"`
|
||||||
LastActivityDate Time `json:"LastActivityDate"`
|
LastActivityDate Time `json:"LastActivityDate"`
|
||||||
Configuration Configuration `json:"Configuration"`
|
Configuration Configuration `json:"Configuration"`
|
||||||
|
// Policy stores the user's permissions.
|
||||||
Policy Policy `json:"Policy"`
|
Policy Policy `json:"Policy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +76,7 @@ func (app *appContext) checkUsers() {
|
|||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
app.info.Printf("Expired user already deleted, ignoring.")
|
app.info.Printf("Expired user already deleted, ignoring.")
|
||||||
|
delete(app.storage.users, id)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
app.info.Printf("%s expired user \"%s\"", termPlural, user.Name)
|
app.info.Printf("%s expired user \"%s\"", termPlural, user.Name)
|
||||||
|
Loading…
Reference in New Issue
Block a user