1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-07 23:02:56 +03:00

Fix default behavior of Room.getBlacklistUnverifiedDevices (#2830)

This commit is contained in:
Faye Duxovni
2022-10-31 14:21:27 -04:00
committed by GitHub
parent 1f3ae4bde2
commit 9fa6616052
3 changed files with 17 additions and 4 deletions

View File

@@ -2926,4 +2926,15 @@ describe("Room", function() {
expect(room.getPendingEvent(ev.getId()!)).toBe(ev); expect(room.getPendingEvent(ev.getId()!)).toBe(ev);
} }
}); });
describe("getBlacklistUnverifiedDevices", () => {
it("defaults to null", () => {
expect(room.getBlacklistUnverifiedDevices()).toBeNull();
});
it("is updated by setBlacklistUnverifiedDevices", () => {
room.setBlacklistUnverifiedDevices(false);
expect(room.getBlacklistUnverifiedDevices()).toBe(false);
});
});
}); });

View File

@@ -1170,8 +1170,9 @@ class MegolmEncryption extends EncryptionAlgorithm {
// The global value is treated as a default for when rooms don't specify a value. // The global value is treated as a default for when rooms don't specify a value.
let isBlacklisting = this.crypto.getGlobalBlacklistUnverifiedDevices(); let isBlacklisting = this.crypto.getGlobalBlacklistUnverifiedDevices();
if (typeof room.getBlacklistUnverifiedDevices() === 'boolean') { const isRoomBlacklisting = room.getBlacklistUnverifiedDevices();
isBlacklisting = room.getBlacklistUnverifiedDevices(); if (typeof isRoomBlacklisting === 'boolean') {
isBlacklisting = isRoomBlacklisting;
} }
// We are happy to use a cached version here: we assume that if we already // We are happy to use a cached version here: we assume that if we already

View File

@@ -1325,8 +1325,9 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
* @return {Boolean} true if blacklisting unverified devices, null * @return {Boolean} true if blacklisting unverified devices, null
* if the global value should be used for this room. * if the global value should be used for this room.
*/ */
public getBlacklistUnverifiedDevices(): boolean { public getBlacklistUnverifiedDevices(): boolean | null {
return !!this.blacklistUnverifiedDevices; if (this.blacklistUnverifiedDevices === undefined) return null;
return this.blacklistUnverifiedDevices;
} }
/** /**