Expose Last.fm's ApiKey to UI
This commit is contained in:
@@ -13,8 +13,6 @@ import (
|
||||
|
||||
const (
|
||||
lastFMAgentName = "lastfm"
|
||||
lastFMAPIKey = "9b94a5515ea66b2da3ec03c12300327e"
|
||||
lastFMAPISecret = "74cb6557cec7171d921af5d7d887c587" // nolint:gosec
|
||||
)
|
||||
|
||||
type lastfmAgent struct {
|
||||
@@ -29,12 +27,8 @@ func lastFMConstructor(ctx context.Context) agents.Interface {
|
||||
l := &lastfmAgent{
|
||||
ctx: ctx,
|
||||
lang: conf.Server.LastFM.Language,
|
||||
apiKey: lastFMAPIKey,
|
||||
secret: lastFMAPISecret,
|
||||
}
|
||||
if conf.Server.LastFM.ApiKey != "" {
|
||||
l.apiKey = conf.Server.LastFM.ApiKey
|
||||
l.secret = conf.Server.LastFM.Secret
|
||||
apiKey: conf.Server.LastFM.ApiKey,
|
||||
secret: conf.Server.LastFM.Secret,
|
||||
}
|
||||
hc := utils.NewCachedHTTPClient(http.DefaultClient, consts.DefaultCachedHttpClientTTL)
|
||||
l.client = NewClient(l.apiKey, l.secret, l.lang, hc)
|
||||
@@ -22,18 +22,13 @@ const (
|
||||
|
||||
var _ = Describe("lastfmAgent", func() {
|
||||
Describe("lastFMConstructor", func() {
|
||||
It("uses default api key and language if not configured", func() {
|
||||
conf.Server.LastFM.ApiKey = ""
|
||||
agent := lastFMConstructor(context.Background())
|
||||
Expect(agent.(*lastfmAgent).apiKey).To(Equal(lastFMAPIKey))
|
||||
Expect(agent.(*lastfmAgent).lang).To(Equal("en"))
|
||||
})
|
||||
|
||||
It("uses configured api key and language", func() {
|
||||
conf.Server.LastFM.ApiKey = "123"
|
||||
conf.Server.LastFM.Secret = "secret"
|
||||
conf.Server.LastFM.Language = "pt"
|
||||
agent := lastFMConstructor(context.Background())
|
||||
Expect(agent.(*lastfmAgent).apiKey).To(Equal("123"))
|
||||
Expect(agent.(*lastfmAgent).secret).To(Equal("secret"))
|
||||
Expect(agent.(*lastfmAgent).lang).To(Equal("pt"))
|
||||
})
|
||||
})
|
||||
@@ -30,13 +30,13 @@ type Router struct {
|
||||
}
|
||||
|
||||
func NewRouter(ds model.DataStore) *Router {
|
||||
r := &Router{ds: ds, apiKey: lastFMAPIKey, secret: lastFMAPISecret}
|
||||
r := &Router{
|
||||
ds: ds,
|
||||
apiKey: conf.Server.LastFM.ApiKey,
|
||||
secret: conf.Server.LastFM.Secret,
|
||||
}
|
||||
r.sessionKeys = &sessionKeys{ds: ds}
|
||||
r.Handler = r.routes()
|
||||
if conf.Server.LastFM.ApiKey != "" {
|
||||
r.apiKey = conf.Server.LastFM.ApiKey
|
||||
r.secret = conf.Server.LastFM.Secret
|
||||
}
|
||||
r.client = NewClient(r.apiKey, r.secret, "en", http.DefaultClient)
|
||||
return r
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user