Add .well-known config option to force disable encryption on room creation (#11120)
* force disable encryption on room creation * test allowChangingEncryption * move into utils/room directory * tests * unit test CreateRoomDialog * remove debug * wait for constructor promises to settle * test case for force_disable * comment * set forced value after resolving checkUserIsAllowedToChangeEncryption * tidy and comments * use label text in test
This commit is contained in:
parent
9d9c55d92e
commit
a692fe2181
9 changed files with 375 additions and 9 deletions
|
@ -24,7 +24,7 @@ import SdkConfig from "../../../SdkConfig";
|
|||
import withValidation, { IFieldState, IValidationResult } from "../elements/Validation";
|
||||
import { _t } from "../../../languageHandler";
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
import { IOpts } from "../../../createRoom";
|
||||
import { checkUserIsAllowedToChangeEncryption, IOpts } from "../../../createRoom";
|
||||
import Field from "../elements/Field";
|
||||
import RoomAliasField from "../elements/RoomAliasField";
|
||||
import LabelledToggleSwitch from "../elements/LabelledToggleSwitch";
|
||||
|
@ -86,11 +86,15 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
|
|||
detailsOpen: false,
|
||||
noFederate: SdkConfig.get().default_federate === false,
|
||||
nameIsValid: false,
|
||||
canChangeEncryption: true,
|
||||
canChangeEncryption: false,
|
||||
};
|
||||
|
||||
cli.doesServerForceEncryptionForPreset(Preset.PrivateChat).then((isForced) =>
|
||||
this.setState({ canChangeEncryption: !isForced }),
|
||||
checkUserIsAllowedToChangeEncryption(cli, Preset.PrivateChat).then(({ allowChange, forcedValue }) =>
|
||||
this.setState((state) => ({
|
||||
canChangeEncryption: allowChange,
|
||||
// override with forcedValue if it is set
|
||||
isEncrypted: forcedValue ?? state.isEncrypted,
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -107,8 +111,7 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
|
|||
const { alias } = this.state;
|
||||
createOpts.room_alias_name = alias.substring(1, alias.indexOf(":"));
|
||||
} else {
|
||||
// If we cannot change encryption we pass `true` for safety, the server should automatically do this for us.
|
||||
opts.encryption = this.state.canChangeEncryption ? this.state.isEncrypted : true;
|
||||
opts.encryption = this.state.isEncrypted;
|
||||
}
|
||||
|
||||
if (this.state.topic) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue