Skip to content

Commit 4ae2a8e

Browse files
committed
backend/banners: fetch banners from staging when app is in dev mode
Previously the app was always fetching banners from the production server. Now when built in dev mode it fetches them from staging, which allows to test new banners before releasing them in production.
1 parent 02be52e commit 4ae2a8e

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

backend/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ func NewBackend(arguments *arguments.Arguments, environment Environment) (*Backe
293293
backend.ratesUpdater = rates.NewRateUpdater(hclient, ratesCache)
294294
backend.ratesUpdater.Observe(backend.Notify)
295295

296-
backend.banners = banners.NewBanners()
296+
backend.banners = banners.NewBanners(backend.DevServers())
297297
backend.banners.Observe(backend.Notify)
298298

299299
backend.bluetooth = bluetooth.New(log)

backend/banners/banners.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ import (
2626
"github.com/sirupsen/logrus"
2727
)
2828

29-
const bannersURL = "https://bitboxapp.shiftcrypto.io/banners.json"
29+
const (
30+
bannersDevURL = "https://bitboxapp.shiftcrypto.dev/banners.json"
31+
32+
bannersProdURL = "https://bitboxapp.shiftcrypto.io/banners.json"
33+
)
3034

3135
// MessageKey enumerates the possible keys in the banners json.
3236
type MessageKey string
@@ -84,9 +88,13 @@ type Banners struct {
8488
}
8589

8690
// NewBanners makes a new Banners instance.
87-
func NewBanners() *Banners {
91+
func NewBanners(devServers bool) *Banners {
92+
url := bannersProdURL
93+
if devServers {
94+
url = bannersDevURL
95+
}
8896
return &Banners{
89-
url: bannersURL,
97+
url: url,
9098
active: map[MessageKey]struct{}{},
9199
log: logging.Get().WithGroup("banners"),
92100
}

backend/banners/banners_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func TestInit(t *testing.T) {
4545
server := httptest.NewServer(handler)
4646
defer server.Close()
4747

48-
banners := NewBanners()
48+
banners := NewBanners(true)
4949
banners.url = server.URL
5050
banners.Init(server.Client())
5151
require.Nil(t, banners.GetMessage(KeyBitBox01))

0 commit comments

Comments
 (0)