From: Florian Forster Date: Sun, 28 Jan 2018 19:54:14 +0000 (+0100) Subject: Unify subscription calls. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e694a51522759a7ed60ee8170b7541bd38fef764;p=kraftakt.git Unify subscription calls. --- diff --git a/gfitsync.go b/gfitsync.go index 7f28bb0..f913134 100644 --- a/gfitsync.go +++ b/gfitsync.go @@ -126,12 +126,11 @@ func fitbitGrantHandler(ctx context.Context, w http.ResponseWriter, r *http.Requ return err } - if err := c.Subscribe(ctx, "activities"); err != nil { - return fmt.Errorf("c.Subscribe() = %v", err) - } - - if err := c.Subscribe(ctx, "sleep"); err != nil { - return fmt.Errorf("c.Subscribe() = %v", err) + for _, collection := range []string{"activities", "sleep"} { + if err := c.Subscribe(ctx, collection); err != nil { + return fmt.Errorf("c.Subscribe(%q) = %v", collection, err) + } + log.Infof(ctx, "Successfully subscribed to %q", collection) } redirectURL := r.URL