From 6ba7e85e2423fcfc11ea932d170edf554da2e149 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Wed, 3 Apr 2019 16:45:41 +0100 Subject: [PATCH] Ensure we have crypto before accessing it in `Room` model If crypto startup has failed, we shouldn't try to access any of its methods. This fixes a variant of this in the `Room` model. --- spec/unit/room.spec.js | 3 +++ src/models/room.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/unit/room.spec.js b/spec/unit/room.spec.js index 4a8ea7e59..1b1d6fb29 100644 --- a/spec/unit/room.spec.js +++ b/spec/unit/room.spec.js @@ -1318,6 +1318,9 @@ describe("Room", function() { // events should already be MatrixEvents return function(event) {return event;}; }, + isCryptoEnabled() { + return true; + }, isRoomEncrypted: function() { return false; }, diff --git a/src/models/room.js b/src/models/room.js index 2696aa6e3..276b9e5cc 100644 --- a/src/models/room.js +++ b/src/models/room.js @@ -496,7 +496,7 @@ Room.prototype.loadMembersIfNeeded = function() { const inMemoryUpdate = this._loadMembers().then((result) => { this.currentState.setOutOfBandMembers(result.memberEvents); // now the members are loaded, start to track the e2e devices if needed - if (this._client.isRoomEncrypted(this.roomId)) { + if (this._client.isCryptoEnabled() && this._client.isRoomEncrypted(this.roomId)) { this._client._crypto.trackRoomDevices(this.roomId); } return result.fromServer;