mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 04:57:37 +03:00
fix(server): remove misleading "Agent not available" warning.
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
dc4e091622
commit
a04167672c
8 changed files with 97 additions and 35 deletions
|
@ -53,13 +53,20 @@ func newPlayTracker(ds model.DataStore, broker events.Broker) *playTracker {
|
|||
m := cache.NewSimpleCache[string, NowPlayingInfo]()
|
||||
p := &playTracker{ds: ds, playMap: m, broker: broker}
|
||||
p.scrobblers = make(map[string]Scrobbler)
|
||||
var enabled []string
|
||||
for name, constructor := range constructors {
|
||||
s := constructor(ds)
|
||||
if s == nil {
|
||||
log.Debug("Scrobbler not available. Missing configuration?", "name", name)
|
||||
continue
|
||||
}
|
||||
enabled = append(enabled, name)
|
||||
if conf.Server.DevEnableBufferedScrobble {
|
||||
s = newBufferedScrobbler(ds, s, name)
|
||||
}
|
||||
p.scrobblers[name] = s
|
||||
}
|
||||
log.Debug("List of scrobblers enabled", "names", enabled)
|
||||
return p
|
||||
}
|
||||
|
||||
|
|
|
@ -35,9 +35,12 @@ var _ = Describe("PlayTracker", func() {
|
|||
ctx = request.WithPlayer(ctx, model.Player{ScrobbleEnabled: true})
|
||||
ds = &tests.MockDataStore{}
|
||||
fake = fakeScrobbler{Authorized: true}
|
||||
Register("fake", func(ds model.DataStore) Scrobbler {
|
||||
Register("fake", func(model.DataStore) Scrobbler {
|
||||
return &fake
|
||||
})
|
||||
Register("disabled", func(model.DataStore) Scrobbler {
|
||||
return nil
|
||||
})
|
||||
tracker = newPlayTracker(ds, events.GetBroker())
|
||||
|
||||
track = model.MediaFile{
|
||||
|
@ -61,6 +64,11 @@ var _ = Describe("PlayTracker", func() {
|
|||
_ = ds.Album(ctx).(*tests.MockAlbumRepo).Put(&album)
|
||||
})
|
||||
|
||||
It("does not register disabled scrobblers", func() {
|
||||
Expect(tracker.(*playTracker).scrobblers).To(HaveKey("fake"))
|
||||
Expect(tracker.(*playTracker).scrobblers).ToNot(HaveKey("disabled"))
|
||||
})
|
||||
|
||||
Describe("NowPlaying", func() {
|
||||
It("sends track to agent", func() {
|
||||
err := tracker.NowPlaying(ctx, "player-1", "player-one", "123")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue