add fallback device rule with "*" pseudo client

This commit is contained in:
sentriz
2020-03-12 12:28:07 +00:00
parent a3fce34cba
commit 1fcf5bcb17
3 changed files with 127 additions and 125 deletions

View File

@@ -118,14 +118,16 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R
play.Count++ // for getAlbumList?type=frequent
c.DB.Save(&play)
}()
client := params.GetOr("c", "*")
client := params.Get("c")
servOpts := serveTrackOptions{
track: track,
musicPath: c.MusicPath,
}
pref := &db.TranscodePreference{}
err = c.DB.
Where("user_id=? AND client=? COLLATE NOCASE", user.ID, client).
Where("user_id=?", user.ID).
Where("client COLLATE NOCASE IN (?)", []string{"*", client}).
Order("client DESC"). // ensure "*" is last if it's there
First(pref).
Error
if gorm.IsRecordNotFoundError(err) {