Skip to content

Commit a9eb4cd

Browse files
committed
deserialize CPA kafka deviceData messages into a types.Blood
Previously a glucose.Glucose was used, which was fine in that we only look at the UserID and UploadID fields, but there are other incompatible fields that can "spoil" the deserialization. BACK-2559
1 parent 970184c commit a9eb4cd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

data/events/alerts.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/tidepool-org/platform/alerts"
1313
"github.com/tidepool-org/platform/auth"
14+
"github.com/tidepool-org/platform/data/types"
1415
"github.com/tidepool-org/platform/data/types/blood/glucose"
1516
"github.com/tidepool-org/platform/data/types/dosingdecision"
1617
"github.com/tidepool-org/platform/devicetokens"
@@ -115,7 +116,10 @@ func isActivityAndActivityOnly(updatedFields []string) bool {
115116
func (c *Consumer) consumeDeviceData(ctx context.Context,
116117
session sarama.ConsumerGroupSession, msg *sarama.ConsumerMessage) error {
117118

118-
datum := &Glucose{}
119+
// The actual type should be either a glucose.Glucose or a
120+
// dosingdecision.DosingDecision, but they both use types.Base, and that's where the
121+
// only fields we need are defined.
122+
datum := &types.Base{}
119123
if _, err := unmarshalMessageValue(msg.Value, datum); err != nil {
120124
return err
121125
}

0 commit comments

Comments
 (0)