fix not taking into account Object.entries yields arrays for the pairs

This commit is contained in:
Bruno Windels 2020-08-31 16:05:57 +02:00
parent 561df45641
commit 78c3157a5f

View File

@ -186,8 +186,8 @@ export class DeviceTracker {
}
_filterVerifiedDeviceKeys(keyQueryDeviceKeysResponse) {
const verifiedKeys = Object.entries(keyQueryDeviceKeysResponse).map((userId, keysByDevice) => {
const verifiedKeys = Object.entries(keysByDevice).filter((deviceId, deviceKeys) => {
const verifiedKeys = Object.entries(keyQueryDeviceKeysResponse).map(([userId, keysByDevice]) => {
const verifiedEntries = Object.entries(keysByDevice).filter(([deviceId, deviceKeys]) => {
const deviceIdOnKeys = deviceKeys["device_id"];
const userIdOnKeys = deviceKeys["user_id"];
if (userIdOnKeys !== userId) {
@ -198,6 +198,7 @@ export class DeviceTracker {
}
return this._verifyUserDeviceKeys(deviceKeys);
});
const verifiedKeys = verifiedEntries.map(([, deviceKeys]) => deviceKeys);
return {userId, verifiedKeys};
});
return verifiedKeys;