// Fitbit recommendation: "If signature verification fails, you should
// respond with a 404"
if !fitbit.CheckSignature(ctx, data, r.Header.Get("X-Fitbit-Signature")) {
- log.Errorf(ctx, "signature mismatch")
- w.WriteHeader(http.StatusNotFound)
- return nil
+ /*
+ log.Errorf(ctx, "signature mismatch")
+ w.WriteHeader(http.StatusNotFound)
+ return nil
+ */
+ } else {
+ log.Warningf(ctx, "TODO(octo): re-enable signature checking, see https://community.fitbit.com/t5/Web-API-Development/Push-notification-signatures-are-currently-invalid/m-p/2496159")
}
if err := delayedHandleNotifications.Call(ctx, data); err != nil {
switch s.CollectionType {
case "activities":
wg.Add(1)
- go func() {
+ go func(s fitbit.Subscription) {
defer wg.Done()
if err := activitiesNotification(ctx, &s); err != nil {
log.Warningf(ctx, "activitiesNotification() = %v", err)
}
- }()
+ }(s) // copies s
case "sleep":
wg.Add(1)
- go func() {
+ go func(s fitbit.Subscription) {
defer wg.Done()
if err := sleepNotification(ctx, &s); err != nil {
log.Warningf(ctx, "sleepNotification() = %v", err)
}
- }()
+ }(s) // copies s
default:
log.Warningf(ctx, "ignoring collection type %q", s.CollectionType)
activities = append(activities, gfit.Activity{
Start: startTime,
End: endTime,
- Type: gfit.ParseFitbitActivity(a.Name),
+ Type: a.Name,
})
}
if err := gfitClient.SetActivities(ctx, activities, tm); err != nil {
}
switch stg.Level {
case fitbit.SleepLevelDeep:
- a.Type = 110 // Deep sleep
+ a.Type = "Deep sleep"
case fitbit.SleepLevelLight:
- a.Type = 109 // Light sleep
+ a.Type = "Light sleep"
case fitbit.SleepLevelREM:
- a.Type = 111 // REM sleep
+ a.Type = "REM sleep"
case fitbit.SleepLevelWake:
- a.Type = 112 // Awake (during sleep cycle)
+ a.Type = "Awake (during sleep cycle)"
default:
log.Warningf(ctx, "unexpected sleep level %v", stg.Level)
continue
}
+
+ activities = append(activities, a)
}
wg.Wait()