From 94972b2340cf8f18d65ff3ebb9a63eed2f4a441b Mon Sep 17 00:00:00 2001 From: Toni Spets Date: Wed, 10 Jan 2024 11:37:00 +0200 Subject: [PATCH] Add context to OLM machine LoadDevices As there's a side effect of going to the crypto store we want the context to at least exist for now. --- crypto/devicelist.go | 5 ++--- crypto/machine.go | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/crypto/devicelist.go b/crypto/devicelist.go index e554480d..bbe06aae 100644 --- a/crypto/devicelist.go +++ b/crypto/devicelist.go @@ -27,9 +27,8 @@ var ( InvalidKeySignature = errors.New("invalid signature on device keys") ) -func (mach *OlmMachine) LoadDevices(user id.UserID) map[id.DeviceID]*id.Device { - // TODO proper context? - return mach.fetchKeys(context.TODO(), []id.UserID{user}, "", true)[user] +func (mach *OlmMachine) LoadDevices(ctx context.Context, user id.UserID) map[id.DeviceID]*id.Device { + return mach.fetchKeys(ctx, []id.UserID{user}, "", true)[user] } func (mach *OlmMachine) storeDeviceSelfSignatures(ctx context.Context, userID id.UserID, deviceID id.DeviceID, resp *mautrix.RespQueryKeys) { diff --git a/crypto/machine.go b/crypto/machine.go index da78eaf7..fc0f1742 100644 --- a/crypto/machine.go +++ b/crypto/machine.go @@ -438,7 +438,7 @@ func (mach *OlmMachine) GetOrFetchDeviceByKey(ctx context.Context, userID id.Use Str("user_id", userID.String()). Str("identity_key", identityKey.String()). Msg("Didn't find identity in crypto store, fetching from server") - devices := mach.LoadDevices(userID) + devices := mach.LoadDevices(ctx, userID) for _, device := range devices { if device.IdentityKey == identityKey { return device, nil