1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

[BREAKING] Change the behaviour of the unverfied devices blacklist flag

Previously the global flag was used as a way to completely ignore the per-room option. This commit makes the per-room and global settings be more flexible to allow users to, for example, blacklist unverified devices in all room with the exception of one or two. This is done by making the global setting a device-level default and the per-room option allowing for 3 states: true, false, and unset (use device default).

Signed-off-by: Travis Ralston <travpc@gmail.com>
This commit is contained in:
Travis Ralston
2017-11-08 17:47:45 -07:00
parent bf462e2840
commit 995f796a5d
4 changed files with 21 additions and 19 deletions

View File

@@ -541,6 +541,12 @@ MegolmEncryption.prototype._getDevicesInRoom = function(room) {
return u.userId;
});
// The global value is treated as a default for when rooms don't specify a value.
let isBlacklisting = this._crypto.getBlacklistUnverifiedDevices();
if (room.getBlacklistUnverifiedDevices() !== null) {
isBlacklisting = room.getBlacklistUnverifiedDevices();
}
// We are happy to use a cached version here: we assume that if we already
// have a list of the user's devices, then we already share an e2e room
// with them, which means that they will have announced any new devices via
@@ -564,9 +570,7 @@ MegolmEncryption.prototype._getDevicesInRoom = function(room) {
}
if (userDevices[deviceId].isBlocked() ||
(userDevices[deviceId].isUnverified() &&
(room.getBlacklistUnverifiedDevices() ||
this._crypto.getGlobalBlacklistUnverifiedDevices()))
(userDevices[deviceId].isUnverified() && isBlacklisting)
) {
delete userDevices[deviceId];
}