Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Replace MatrixClient.setGlobalBlacklistUnverifiedDevices by `Matrix…
Browse files Browse the repository at this point in the history
…Client.CryptoApi.globalBlacklistUnverifiedDevices`
  • Loading branch information
florianduros committed Oct 16, 2024
1 parent fab2a3b commit dfa9eda
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/components/structures/MatrixChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1707,9 +1707,10 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
}
}

if (cli.getCrypto()) {
const crypto = cli.getCrypto();
if (crypto) {
const blacklistEnabled = SettingsStore.getValueAt(SettingLevel.DEVICE, "blacklistUnverifiedDevices");
cli.setGlobalBlacklistUnverifiedDevices(blacklistEnabled);
crypto.globalBlacklistUnverifiedDevices = blacklistEnabled;

// With cross-signing enabled, we send to unknown devices
// without prompting. Any bad-device status the user should
Expand Down
3 changes: 2 additions & 1 deletion src/components/views/settings/CryptographyPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export default class CryptographyPanel extends React.Component<IProps, IState> {
};

private updateBlacklistDevicesFlag = (checked: boolean): void => {
MatrixClientPeg.safeGet().setGlobalBlacklistUnverifiedDevices(checked);
const crypto = MatrixClientPeg.safeGet().getCrypto();
if (crypto) crypto.globalBlacklistUnverifiedDevices = checked;
};
}
2 changes: 1 addition & 1 deletion test/components/structures/MatrixChat-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ describe("<MatrixChat />", () => {
}),
getVisibleRooms: jest.fn().mockReturnValue([]),
getRooms: jest.fn().mockReturnValue([]),
setGlobalBlacklistUnverifiedDevices: jest.fn(),
setGlobalErrorOnUnknownDevices: jest.fn(),
getCrypto: jest.fn().mockReturnValue({
getVerificationRequestsToDeviceInProgress: jest.fn().mockReturnValue([]),
Expand All @@ -135,6 +134,7 @@ describe("<MatrixChat />", () => {
getVersion: jest.fn().mockReturnValue("1"),
setDeviceIsolationMode: jest.fn(),
userHasCrossSigningKeys: jest.fn(),
globalBlacklistUnverifiedDevices: false,
}),
// This needs to not finish immediately because we need to test the screen appears
bootstrapCrossSigning: jest.fn().mockImplementation(() => bootstrapDeferred.promise),
Expand Down

0 comments on commit dfa9eda

Please sign in to comment.