You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-01 04:43:29 +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.
|
* Enable end-to-end encryption for a room.
|
||||||
* @param {string} roomId The room ID to enable encryption in.
|
* @param {string} roomId The room ID to enable encryption in.
|
||||||
* @param {object} config The encryption config for the room.
|
* @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) {
|
MatrixClient.prototype.setRoomEncryption = function(roomId, config) {
|
||||||
if (!this._crypto) {
|
if (!this._crypto) {
|
||||||
throw new Error("End-to-End encryption disabled");
|
throw new Error("End-to-End encryption disabled");
|
||||||
}
|
}
|
||||||
this._crypto.setRoomEncryption(roomId, config);
|
return this._crypto.setRoomEncryption(roomId, config);
|
||||||
return Promise.resolve();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -580,7 +580,7 @@ Crypto.prototype.getEventSenderDeviceInfo = function(event) {
|
|||||||
* @param {boolean=} inhibitDeviceQuery true to suppress device list query for
|
* @param {boolean=} inhibitDeviceQuery true to suppress device list query for
|
||||||
* users in the room (for now)
|
* 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
|
// if we already have encryption in this room, we should ignore this event
|
||||||
// (for now at least. maybe we should alert the user somehow?)
|
// (for now at least. maybe we should alert the user somehow?)
|
||||||
const existingConfig = this._sessionStore.getEndToEndRoom(roomId);
|
const existingConfig = this._sessionStore.getEndToEndRoom(roomId);
|
||||||
@@ -842,7 +842,7 @@ Crypto.prototype.onCryptoEvent = async function(event) {
|
|||||||
try {
|
try {
|
||||||
// inhibit the device list refresh for now - it will happen once we've
|
// inhibit the device list refresh for now - it will happen once we've
|
||||||
// finished processing the sync, in _onSyncCompleted.
|
// finished processing the sync, in _onSyncCompleted.
|
||||||
this.setRoomEncryption(roomId, content, true);
|
await this.setRoomEncryption(roomId, content, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Error configuring encryption in room " + roomId +
|
console.error("Error configuring encryption in room " + roomId +
|
||||||
":", e);
|
":", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user