diff --git a/src/client.js b/src/client.js index 22a88e6ac..ae6c4fe1a 100644 --- a/src/client.js +++ b/src/client.js @@ -590,14 +590,13 @@ MatrixClient.prototype.isEventSenderVerified = async function(event) { * Enable end-to-end encryption for a room. * @param {string} roomId The room ID to enable encryption in. * @param {object} config The encryption config for the room. - * @return {Object} A promise that will resolve when encryption is setup. + * @return {Promise} A promise that will resolve when encryption is set up. */ MatrixClient.prototype.setRoomEncryption = function(roomId, config) { if (!this._crypto) { throw new Error("End-to-End encryption disabled"); } - this._crypto.setRoomEncryption(roomId, config); - return Promise.resolve(); + return this._crypto.setRoomEncryption(roomId, config); }; /** diff --git a/src/crypto/index.js b/src/crypto/index.js index 9847f0f24..0bc6533d3 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -580,7 +580,7 @@ Crypto.prototype.getEventSenderDeviceInfo = function(event) { * @param {boolean=} inhibitDeviceQuery true to suppress device list query for * users in the room (for now) */ -Crypto.prototype.setRoomEncryption = function(roomId, config, inhibitDeviceQuery) { +Crypto.prototype.setRoomEncryption = async function(roomId, config, inhibitDeviceQuery) { // if we already have encryption in this room, we should ignore this event // (for now at least. maybe we should alert the user somehow?) const existingConfig = this._sessionStore.getEndToEndRoom(roomId); @@ -842,7 +842,7 @@ Crypto.prototype.onCryptoEvent = async function(event) { try { // inhibit the device list refresh for now - it will happen once we've // finished processing the sync, in _onSyncCompleted. - this.setRoomEncryption(roomId, content, true); + await this.setRoomEncryption(roomId, content, true); } catch (e) { console.error("Error configuring encryption in room " + roomId + ":", e);