Unify subscription calls.
authorFlorian Forster <ff@octo.it>
Sun, 28 Jan 2018 19:54:14 +0000 (20:54 +0100)
committerFlorian Forster <ff@octo.it>
Sun, 28 Jan 2018 19:54:14 +0000 (20:54 +0100)
gfitsync.go

index 7f28bb0..f913134 100644 (file)
@@ -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