ensure /keys/query devices have the keys we need

This commit is contained in:
Bruno Windels 2020-09-08 10:51:01 +02:00
parent c32ac2c764
commit 3e100ff5ec

View File

@ -26,8 +26,8 @@ function deviceKeysAsDeviceIdentity(deviceSection) {
return {
userId,
deviceId,
ed25519Key: deviceSection.keys?.[`ed25519:${deviceId}`],
curve25519Key: deviceSection.keys?.[`curve25519:${deviceId}`],
ed25519Key: deviceSection.keys[`ed25519:${deviceId}`],
curve25519Key: deviceSection.keys[`curve25519:${deviceId}`],
algorithms: deviceSection.algorithms,
displayName: deviceSection.unsigned?.device_display_name,
};
@ -200,6 +200,11 @@ export class DeviceTracker {
if (deviceIdOnKeys !== deviceId) {
return false;
}
const ed25519Key = deviceKeys.keys?.[`ed25519:${deviceId}`];
const curve25519Key = deviceKeys.keys?.[`curve25519:${deviceId}`];
if (typeof ed25519Key !== "string" || typeof curve25519Key !== "string") {
return false;
}
// don't store our own device
if (userId === this._ownUserId && deviceId === this._ownDeviceId) {
return false;