From 3d30ad843f057b9042c4aef4304390950a35b83e Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sun, 22 Jan 2017 01:29:33 +0100 Subject: [PATCH] make it work --- src/client.js | 11 +++++++++++ src/crypto/algorithms/megolm.js | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/client.js b/src/client.js index c28cd2a5a..4db1ea7bc 100644 --- a/src/client.js +++ b/src/client.js @@ -418,6 +418,17 @@ MatrixClient.prototype.setGlobalBlacklistUnverifiedDevices = function(value) { this._crypto.setGlobalBlacklistUnverifiedDevices(value); }; +/** + * @return {boolean} whether to unilaterally blacklist all + * unverified devices + */ +MatrixClient.prototype.getGlobalBlacklistUnverifiedDevices = function() { + if (this._crypto === null) { + throw new Error("End-to-end encryption disabled"); + } + return this._crypto.getGlobalBlacklistUnverifiedDevices(); +}; + /** * Get e2e information on the device that sent an event * diff --git a/src/crypto/algorithms/megolm.js b/src/crypto/algorithms/megolm.js index d583e56c3..477a7ced3 100644 --- a/src/crypto/algorithms/megolm.js +++ b/src/crypto/algorithms/megolm.js @@ -475,7 +475,8 @@ MegolmEncryption.prototype._getDevicesInRoom = function(room) { // // XXX: what if the cache is stale, and the user left the room we had in common // and then added new devices before joining this one? --Matthew - return this._crypto.downloadKeys(roomMembers, false).then(function(devices) { + var self = this; + return self._crypto.downloadKeys(roomMembers, false).then(function(devices) { // remove any blocked (aka blacklisted) devices for (const userId in devices) { if (!devices.hasOwnProperty(userId)) { @@ -491,7 +492,7 @@ MegolmEncryption.prototype._getDevicesInRoom = function(room) { if (userDevices[deviceId].isBlocked() || (userDevices[deviceId].isUnverified() && (room.getBlacklistUnverifiedDevices() || - this._crypto.getGlobalBlacklistUnverifiedDevices()))) + self._crypto.getGlobalBlacklistUnverifiedDevices()))) { delete userDevices[deviceId]; }