Add ability to revert to non-hyphenated user IDs

The first 10.7.0 build i tried used hyphens, but a later one didn't.
emails.json can now be converted between the two forms depending on what
the server uses.
This commit is contained in:
Harvey Tindall
2020-12-18 15:44:19 +00:00
parent c79f86137e
commit ee6f81b9e9
3 changed files with 54 additions and 11 deletions
+8 -2
View File
@@ -44,6 +44,7 @@ type Jellyfin struct {
CacheExpiry time.Time
cacheLength int
noFail bool
Hyphens bool
timeoutHandler common.TimeoutHandler
}
@@ -208,8 +209,8 @@ func (jf *Jellyfin) post(url string, data map[string]interface{}, response bool)
}
// DeleteUser deletes the user corresponding to the provided ID.
func (jf *Jellyfin) DeleteUser(id string) (int, error) {
url := fmt.Sprintf("%s/Users/%s", jf.Server, id)
func (jf *Jellyfin) DeleteUser(userID string) (int, error) {
url := fmt.Sprintf("%s/Users/%s", jf.Server, userID)
req, _ := http.NewRequest("DELETE", url, nil)
for name, value := range jf.header {
req.Header.Add(name, value)
@@ -239,6 +240,11 @@ func (jf *Jellyfin) GetUsers(public bool) ([]map[string]interface{}, int, error)
json.Unmarshal([]byte(data), &result)
jf.userCache = result
jf.CacheExpiry = time.Now().Add(time.Minute * time.Duration(jf.cacheLength))
if id, ok := result[0]["Id"]; ok {
if id.(string)[8] == '-' {
jf.Hyphens = true
}
}
return result, status, nil
}
return jf.userCache, 200, nil