Skip to content

Commit 7d78033

Browse files
RiotRobotduxovni
andauthored
[Backport staging] Fix default behavior of Room.getBlacklistUnverifiedDevices (matrix-org#2831)
Co-authored-by: Faye Duxovni <[email protected]>
1 parent 545a743 commit 7d78033

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

spec/unit/room.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2737,4 +2737,15 @@ describe("Room", function() {
27372737
expect(room.getPendingEvent(ev.getId())).toBe(ev);
27382738
}
27392739
});
2740+
2741+
describe("getBlacklistUnverifiedDevices", () => {
2742+
it("defaults to null", () => {
2743+
expect(room.getBlacklistUnverifiedDevices()).toBeNull();
2744+
});
2745+
2746+
it("is updated by setBlacklistUnverifiedDevices", () => {
2747+
room.setBlacklistUnverifiedDevices(false);
2748+
expect(room.getBlacklistUnverifiedDevices()).toBe(false);
2749+
});
2750+
});
27402751
});

src/crypto/algorithms/megolm.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,8 +1134,9 @@ class MegolmEncryption extends EncryptionAlgorithm {
11341134

11351135
// The global value is treated as a default for when rooms don't specify a value.
11361136
let isBlacklisting = this.crypto.getGlobalBlacklistUnverifiedDevices();
1137-
if (typeof room.getBlacklistUnverifiedDevices() === 'boolean') {
1138-
isBlacklisting = room.getBlacklistUnverifiedDevices();
1137+
const isRoomBlacklisting = room.getBlacklistUnverifiedDevices();
1138+
if (typeof isRoomBlacklisting === 'boolean') {
1139+
isBlacklisting = isRoomBlacklisting;
11391140
}
11401141

11411142
// We are happy to use a cached version here: we assume that if we already

src/models/room.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,8 +1325,9 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
13251325
* @return {Boolean} true if blacklisting unverified devices, null
13261326
* if the global value should be used for this room.
13271327
*/
1328-
public getBlacklistUnverifiedDevices(): boolean {
1329-
return !!this.blacklistUnverifiedDevices;
1328+
public getBlacklistUnverifiedDevices(): boolean | null {
1329+
if (this.blacklistUnverifiedDevices === undefined) return null;
1330+
return this.blacklistUnverifiedDevices;
13301331
}
13311332

13321333
/**

0 commit comments

Comments
 (0)