You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-29 16:43:09 +03:00
Make Crypto.setRoomEncryption asynchronous
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user