mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
don't store or return our own device
This commit is contained in:
parent
eda15e1141
commit
e22131bf57
@ -50,6 +50,8 @@ export class Session {
|
|||||||
storage,
|
storage,
|
||||||
getSyncToken: () => this.syncToken,
|
getSyncToken: () => this.syncToken,
|
||||||
olmUtil: this._olmUtil,
|
olmUtil: this._olmUtil,
|
||||||
|
ownUserId: sessionInfo.userId,
|
||||||
|
ownDeviceId: sessionInfo.deviceId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,11 +34,13 @@ function deviceKeysAsDeviceIdentity(deviceSection) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class DeviceTracker {
|
export class DeviceTracker {
|
||||||
constructor({storage, getSyncToken, olmUtil}) {
|
constructor({storage, getSyncToken, olmUtil, ownUserId, ownDeviceId}) {
|
||||||
this._storage = storage;
|
this._storage = storage;
|
||||||
this._getSyncToken = getSyncToken;
|
this._getSyncToken = getSyncToken;
|
||||||
this._identityChangedForRoom = null;
|
this._identityChangedForRoom = null;
|
||||||
this._olmUtil = olmUtil;
|
this._olmUtil = olmUtil;
|
||||||
|
this._ownUserId = ownUserId;
|
||||||
|
this._ownDeviceId = ownDeviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
async writeDeviceChanges(deviceLists, txn) {
|
async writeDeviceChanges(deviceLists, txn) {
|
||||||
@ -198,6 +200,10 @@ export class DeviceTracker {
|
|||||||
if (deviceIdOnKeys !== deviceId) {
|
if (deviceIdOnKeys !== deviceId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// don't store our own device
|
||||||
|
if (userId === this._ownUserId && deviceId === this._ownDeviceId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return this._hasValidSignature(deviceKeys);
|
return this._hasValidSignature(deviceKeys);
|
||||||
});
|
});
|
||||||
const verifiedKeys = verifiedEntries.map(([, deviceKeys]) => deviceKeys);
|
const verifiedKeys = verifiedEntries.map(([, deviceKeys]) => deviceKeys);
|
||||||
@ -258,6 +264,10 @@ export class DeviceTracker {
|
|||||||
if (queriedDevices && queriedDevices.length) {
|
if (queriedDevices && queriedDevices.length) {
|
||||||
flattenedDevices = flattenedDevices.concat(queriedDevices);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user