From 96e93e5a5a888290ae41fc2db3c1d540992d91a1 Mon Sep 17 00:00:00 2001 From: Johan McGwire Date: Fri, 21 Oct 2022 13:40:47 -0400 Subject: [PATCH] fix context.TODO() --- storage/mongodb/push.go | 4 ++-- storage/mongodb/pushcert.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/storage/mongodb/push.go b/storage/mongodb/push.go index 1e65283..e096122 100644 --- a/storage/mongodb/push.go +++ b/storage/mongodb/push.go @@ -16,13 +16,13 @@ func (m MongoDBStorage) RetrievePushInfo(ctx context.Context, ids []string) (map "$in": ids, }, } - cursor, err := m.CheckinCollection.Find(context.TODO(), filter) + cursor, err := m.CheckinCollection.Find(ctx, filter) if err != nil { return nil, err } records := []DeviceCheckinRecord{} - err = cursor.All(context.TODO(), &records) + err = cursor.All(ctx, &records) if err != nil { return nil, err } diff --git a/storage/mongodb/pushcert.go b/storage/mongodb/pushcert.go index dec63ce..69e9500 100644 --- a/storage/mongodb/pushcert.go +++ b/storage/mongodb/pushcert.go @@ -27,7 +27,7 @@ func (m MongoDBStorage) IsPushCertStale(ctx context.Context, topic string, stale "topic": topic, } res := PushCertRecord{} - err := m.PushCertCollection.FindOne(context.TODO(), filter, options.FindOne().SetSort(latestSort)).Decode(&res) + err := m.PushCertCollection.FindOne(ctx, filter, options.FindOne().SetSort(latestSort)).Decode(&res) if err != nil { return false, err } @@ -39,7 +39,7 @@ func (m MongoDBStorage) RetrievePushCert(ctx context.Context, topic string) (cer "topic": topic, } res := PushCertRecord{} - err = m.PushCertCollection.FindOne(context.TODO(), filter, options.FindOne().SetSort(latestSort)).Decode(&res) + err = m.PushCertCollection.FindOne(ctx, filter, options.FindOne().SetSort(latestSort)).Decode(&res) if err != nil { return nil, "", err } @@ -58,7 +58,7 @@ func (m MongoDBStorage) StorePushCert(ctx context.Context, pemCert, pemKey []byt return err } - _, err = m.PushCertCollection.InsertOne(context.TODO(), PushCertRecord{ + _, err = m.PushCertCollection.InsertOne(ctx, PushCertRecord{ Timestamp: strconv.FormatInt(time.Now().UnixNano(), 10), Certificate: string(pemCert), PrivateKey: string(pemKey),