projects
/
kraftakt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Connect handlers: don't call {fitbit,gfit}.NewClient().
[kraftakt.git]
/
kraftakt.go
diff --git
a/kraftakt.go
b/kraftakt.go
index
e84b03a
..
8d56299
100644
(file)
--- a/
kraftakt.go
+++ b/
kraftakt.go
@@
-137,12
+137,7
@@
func loginHandler(_ context.Context, w http.ResponseWriter, r *http.Request, _ *
}
func fitbitConnectHandler(ctx context.Context, w http.ResponseWriter, r *http.Request, u *app.User) error {
}
func fitbitConnectHandler(ctx context.Context, w http.ResponseWriter, r *http.Request, u *app.User) error {
- c, err := fitbit.NewClient(ctx, "", u)
- if err != nil {
- return err
- }
-
- http.Redirect(w, r, c.AuthURL(ctx), http.StatusTemporaryRedirect)
+ http.Redirect(w, r, fitbit.AuthURL(ctx, u), http.StatusTemporaryRedirect)
return nil
}
return nil
}
@@
-202,12
+197,7
@@
func fitbitDisconnectHandler(ctx context.Context, w http.ResponseWriter, r *http
}
func googleConnectHandler(ctx context.Context, w http.ResponseWriter, r *http.Request, u *app.User) error {
}
func googleConnectHandler(ctx context.Context, w http.ResponseWriter, r *http.Request, u *app.User) error {
- c, err := gfit.NewClient(ctx, u)
- if err != nil {
- return err
- }
-
- http.Redirect(w, r, c.AuthURL(ctx), http.StatusTemporaryRedirect)
+ http.Redirect(w, r, gfit.AuthURL(ctx, u), http.StatusTemporaryRedirect)
return nil
}
return nil
}
@@
-287,6
+277,8
@@
func fitbitNotifyHandler(ctx context.Context, w http.ResponseWriter, r *http.Req
// handleNotifications parses fitbit notifications and requests the individual
// activities from Fitbit. It is executed asynchronously via the delay package.
func handleNotifications(ctx context.Context, payload []byte) error {
// handleNotifications parses fitbit notifications and requests the individual
// activities from Fitbit. It is executed asynchronously via the delay package.
func handleNotifications(ctx context.Context, payload []byte) error {
+ log.Debugf(ctx, "NOTIFY -> %s", payload)
+
if err := app.LoadConfig(ctx); err != nil {
return err
}
if err := app.LoadConfig(ctx); err != nil {
return err
}
@@
-312,7
+304,7
@@
func handleNotifications(ctx context.Context, payload []byte) error {
}
func handleNotification(ctx context.Context, s *fitbit.Subscription) error {
}
func handleNotification(ctx context.Context, s *fitbit.Subscription) error {
- u, err :=
app.UserBy
ID(ctx, s.SubscriptionID)
+ u, err :=
fitbit.UserFromSubscriber
ID(ctx, s.SubscriptionID)
if err != nil {
return err
}
if err != nil {
return err
}