From e22131bf57a3fb89f6b538cdc6284c4564d581c0 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 3 Sep 2020 15:28:03 +0200 Subject: [PATCH] don't store or return our own device --- src/matrix/Session.js | 2 ++ src/matrix/e2ee/DeviceTracker.js | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/matrix/Session.js b/src/matrix/Session.js index 803aadc8..6929430f 100644 --- a/src/matrix/Session.js +++ b/src/matrix/Session.js @@ -50,6 +50,8 @@ export class Session { storage, getSyncToken: () => this.syncToken, olmUtil: this._olmUtil, + ownUserId: sessionInfo.userId, + ownDeviceId: sessionInfo.deviceId, }); } } diff --git a/src/matrix/e2ee/DeviceTracker.js b/src/matrix/e2ee/DeviceTracker.js index 095730ff..84da2f37 100644 --- a/src/matrix/e2ee/DeviceTracker.js +++ b/src/matrix/e2ee/DeviceTracker.js @@ -34,11 +34,13 @@ function deviceKeysAsDeviceIdentity(deviceSection) { } export class DeviceTracker { - constructor({storage, getSyncToken, olmUtil}) { + constructor({storage, getSyncToken, olmUtil, ownUserId, ownDeviceId}) { this._storage = storage; this._getSyncToken = getSyncToken; this._identityChangedForRoom = null; this._olmUtil = olmUtil; + this._ownUserId = ownUserId; + this._ownDeviceId = ownDeviceId; } async writeDeviceChanges(deviceLists, txn) { @@ -198,6 +200,10 @@ export class DeviceTracker { if (deviceIdOnKeys !== deviceId) { return false; } + // don't store our own device + if (userId === this._ownUserId && deviceId === this._ownDeviceId) { + return false; + } return this._hasValidSignature(deviceKeys); }); const verifiedKeys = verifiedEntries.map(([, deviceKeys]) => deviceKeys); @@ -258,6 +264,10 @@ export class DeviceTracker { if (queriedDevices && queriedDevices.length) { flattenedDevices = flattenedDevices.concat(queriedDevices); } - return flattenedDevices; + // filter out our own devices if it got in somehow (even though we should not store it) + const devices = flattenedDevices.filter(device => { + return !(device.userId === this._ownUserId && device.deviceId === this._ownDeviceId); + }); + return devices; } }