mirror of
https://github.com/navidrome/navidrome.git
synced 2025-05-29 14:49:24 +03:00
Revert "refactor(server): simplify lastfm agent initialization logic"
This reverts commit 6f52c0201cdc6e92bf4e47394d79767db9c33640. Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
924354eb4b
commit
dd1d3907b4
@ -45,7 +45,7 @@ func createAgents(ds model.DataStore) *Agents {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
enabled = append(enabled, name)
|
enabled = append(enabled, name)
|
||||||
res = append(res, agent)
|
res = append(res, init(ds))
|
||||||
}
|
}
|
||||||
log.Debug("List of agents enabled", "names", enabled)
|
log.Debug("List of agents enabled", "names", enabled)
|
||||||
|
|
||||||
|
@ -344,10 +344,22 @@ func (l *lastfmAgent) IsAuthorized(ctx context.Context, userId string) bool {
|
|||||||
func init() {
|
func init() {
|
||||||
conf.AddHook(func() {
|
conf.AddHook(func() {
|
||||||
agents.Register(lastFMAgentName, func(ds model.DataStore) agents.Interface {
|
agents.Register(lastFMAgentName, func(ds model.DataStore) agents.Interface {
|
||||||
return lastFMConstructor(ds)
|
// This is a workaround for the fact that a (Interface)(nil) is not the same as a (*lastfmAgent)(nil)
|
||||||
|
// See https://go.dev/doc/faq#nil_error
|
||||||
|
a := lastFMConstructor(ds)
|
||||||
|
if a != nil {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
return nil
|
||||||
})
|
})
|
||||||
scrobbler.Register(lastFMAgentName, func(ds model.DataStore) scrobbler.Scrobbler {
|
scrobbler.Register(lastFMAgentName, func(ds model.DataStore) scrobbler.Scrobbler {
|
||||||
return lastFMConstructor(ds)
|
// Same as above - this is a workaround for the fact that a (Scrobbler)(nil) is not the same as a (*lastfmAgent)(nil)
|
||||||
|
// See https://go.dev/doc/faq#nil_error
|
||||||
|
a := lastFMConstructor(ds)
|
||||||
|
if a != nil {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
return nil
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user