🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Revert "refactor(server): simplify lastfm agent initialization logic"
Deluandd1d3907b41f
diff --git a/core/agents/agents.go b/core/agents/agents.goindex 9814c9f18..50a1e04ad 100644--- a/core/agents/agents.go+++ b/core/agents/agents.go@@ -45,7 +45,7 @@ func createAgents(ds model.DataStore) *Agents {continue}enabled = append(enabled, name)- res = append(res, agent)+ res = append(res, init(ds))}log.Debug("List of agents enabled", "names", enabled)diff --git a/core/agents/lastfm/agent.go b/core/agents/lastfm/agent.goindex 78ed96678..3f5f44d20 100644--- a/core/agents/lastfm/agent.go+++ b/core/agents/lastfm/agent.go@@ -344,10 +344,22 @@ func (l *lastfmAgent) IsAuthorized(ctx context.Context, userId string) bool {func init() {conf.AddHook(func() {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 {- 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})})}