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
Merge pull request #1150 from matrix-org/dbkr/dont_error_on_unknown_devices
Add an option to ignore unverified devices
This commit is contained in:
@@ -946,6 +946,35 @@ MatrixClient.prototype.getGlobalBlacklistUnverifiedDevices = function() {
|
||||
return this._crypto.getGlobalBlacklistUnverifiedDevices();
|
||||
};
|
||||
|
||||
/**
|
||||
* Set whether sendMessage in a room with unknown and unverified devices
|
||||
* should throw an error and not send them message. This has 'Global' for
|
||||
* symmetry with setGlobalBlacklistUnverifiedDevices but there is currently
|
||||
* no room-level equivalent for this setting.
|
||||
*
|
||||
* This API is currently UNSTABLE and may change or be removed without notice.
|
||||
*
|
||||
* @param {boolean} value whether error on unknown devices
|
||||
*/
|
||||
MatrixClient.prototype.setGlobalErrorOnUnknownDevices = function(value) {
|
||||
if (this._crypto === null) {
|
||||
throw new Error("End-to-end encryption disabled");
|
||||
}
|
||||
this._crypto.setGlobalErrorOnUnknownDevices(value);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean} whether to error on unknown devices
|
||||
*
|
||||
* This API is currently UNSTABLE and may change or be removed without notice.
|
||||
*/
|
||||
MatrixClient.prototype.getGlobalErrorOnUnknownDevices = function() {
|
||||
if (this._crypto === null) {
|
||||
throw new Error("End-to-end encryption disabled");
|
||||
}
|
||||
return this._crypto.getGlobalErrorOnUnknownDevices();
|
||||
};
|
||||
|
||||
/**
|
||||
* Add methods that call the corresponding method in this._crypto
|
||||
*
|
||||
|
||||
@@ -736,7 +736,9 @@ MegolmEncryption.prototype.encryptMessage = async function(room, eventType, cont
|
||||
|
||||
// check if any of these devices are not yet known to the user.
|
||||
// if so, warn the user so they can verify or ignore.
|
||||
self._checkForUnknownDevices(devicesInRoom);
|
||||
if (this._crypto.getGlobalErrorOnUnknownDevices()) {
|
||||
self._checkForUnknownDevices(devicesInRoom);
|
||||
}
|
||||
|
||||
const session = await self._ensureOutboundSession(devicesInRoom, blocked);
|
||||
const payloadJson = {
|
||||
|
||||
@@ -177,6 +177,7 @@ export default function Crypto(baseApis, sessionStore, userId, deviceId,
|
||||
this._deviceKeys = {};
|
||||
|
||||
this._globalBlacklistUnverifiedDevices = false;
|
||||
this._globalErrorOnUnknownDevices = true;
|
||||
|
||||
this._outgoingRoomKeyRequestManager = new OutgoingRoomKeyRequestManager(
|
||||
baseApis, this._deviceId, this._cryptoStore,
|
||||
@@ -1210,6 +1211,29 @@ Crypto.prototype.getGlobalBlacklistUnverifiedDevices = function() {
|
||||
return this._globalBlacklistUnverifiedDevices;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set whether sendMessage in a room with unknown and unverified devices
|
||||
* should throw an error and not send them message. This has 'Global' for
|
||||
* symmertry with setGlobalBlacklistUnverifiedDevices but there is currently
|
||||
* no room-level equivalent for this setting.
|
||||
*
|
||||
* This API is currently UNSTABLE and may change or be removed without notice.
|
||||
*
|
||||
* @param {boolean} value whether error on unknown devices
|
||||
*/
|
||||
Crypto.prototype.setGlobalErrorOnUnknownDevices = function(value) {
|
||||
this._globalErrorOnUnknownDevices = value;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean} whether to error on unknown devices
|
||||
*
|
||||
* This API is currently UNSTABLE and may change or be removed without notice.
|
||||
*/
|
||||
Crypto.prototype.getGlobalErrorOnUnknownDevices = function() {
|
||||
return this._globalErrorOnUnknownDevices;
|
||||
};
|
||||
|
||||
/**
|
||||
* Upload the device keys to the homeserver.
|
||||
* @return {object} A promise that will resolve when the keys are uploaded.
|
||||
|
||||
Reference in New Issue
Block a user