From 1f8e3e5d43f45c57b69d6b51065f61b0f998ade0 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 7 Aug 2018 14:48:07 +0200 Subject: [PATCH] await room.getEncryptionTargetMembers in cryptodevices --- src/cryptodevices.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/cryptodevices.js b/src/cryptodevices.js index 92237ce7f5..246fae3d73 100644 --- a/src/cryptodevices.js +++ b/src/cryptodevices.js @@ -43,27 +43,26 @@ export function markAllDevicesKnown(matrixClient, devices) { * @return {Promise} A promise which resolves to a map userId->deviceId->{@link * module:crypto~DeviceInfo|DeviceInfo}. */ -export function getUnknownDevicesForRoom(matrixClient, room) { - const roomMembers = room.getEncryptionTargetMembers().map((m) => { +export async function getUnknownDevicesForRoom(matrixClient, room) { + const roomMembers = await room.getEncryptionTargetMembers().map((m) => { return m.userId; }); - return matrixClient.downloadKeys(roomMembers, false).then((devices) => { - const unknownDevices = {}; - // This is all devices in this room, so find the unknown ones. - Object.keys(devices).forEach((userId) => { - Object.keys(devices[userId]).map((deviceId) => { - const device = devices[userId][deviceId]; + const devices = await matrixClient.downloadKeys(roomMembers, false); + const unknownDevices = {}; + // This is all devices in this room, so find the unknown ones. + Object.keys(devices).forEach((userId) => { + Object.keys(devices[userId]).map((deviceId) => { + const device = devices[userId][deviceId]; - if (device.isUnverified() && !device.isKnown()) { - if (unknownDevices[userId] === undefined) { - unknownDevices[userId] = {}; - } - unknownDevices[userId][deviceId] = device; + if (device.isUnverified() && !device.isKnown()) { + if (unknownDevices[userId] === undefined) { + unknownDevices[userId] = {}; } - }); + unknownDevices[userId][deviceId] = device; + } }); - return unknownDevices; }); + return unknownDevices; } function focusComposer() {