diff --git a/spec/unit/room.spec.ts b/spec/unit/room.spec.ts index ed15b61fe..d9a30e10c 100644 --- a/spec/unit/room.spec.ts +++ b/spec/unit/room.spec.ts @@ -2926,4 +2926,15 @@ describe("Room", function() { 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); + }); + }); }); diff --git a/src/crypto/algorithms/megolm.ts b/src/crypto/algorithms/megolm.ts index 170172a34..7fcbae582 100644 --- a/src/crypto/algorithms/megolm.ts +++ b/src/crypto/algorithms/megolm.ts @@ -1170,8 +1170,9 @@ class MegolmEncryption extends EncryptionAlgorithm { // The global value is treated as a default for when rooms don't specify a value. let isBlacklisting = this.crypto.getGlobalBlacklistUnverifiedDevices(); - if (typeof room.getBlacklistUnverifiedDevices() === 'boolean') { - isBlacklisting = room.getBlacklistUnverifiedDevices(); + const isRoomBlacklisting = room.getBlacklistUnverifiedDevices(); + if (typeof isRoomBlacklisting === 'boolean') { + isBlacklisting = isRoomBlacklisting; } // We are happy to use a cached version here: we assume that if we already diff --git a/src/models/room.ts b/src/models/room.ts index a2a1e7140..132908e33 100644 --- a/src/models/room.ts +++ b/src/models/room.ts @@ -1325,8 +1325,9 @@ export class Room extends ReadReceipt { * @return {Boolean} true if blacklisting unverified devices, null * if the global value should be used for this room. */ - public getBlacklistUnverifiedDevices(): boolean { - return !!this.blacklistUnverifiedDevices; + public getBlacklistUnverifiedDevices(): boolean | null { + if (this.blacklistUnverifiedDevices === undefined) return null; + return this.blacklistUnverifiedDevices; } /**