diff --git a/src/components/views/dialogs/CreateRoomDialog.tsx b/src/components/views/dialogs/CreateRoomDialog.tsx index b15fb800d26..277b2ecf074 100644 --- a/src/components/views/dialogs/CreateRoomDialog.tsx +++ b/src/components/views/dialogs/CreateRoomDialog.tsx @@ -48,6 +48,7 @@ interface IState { joinRule: JoinRule; isPublic: boolean; isEncrypted: boolean; + useMls: boolean; name: string; topic: string; alias: string; @@ -77,6 +78,7 @@ export default class CreateRoomDialog extends React.Component { this.state = { isPublic: this.props.defaultPublic || false, isEncrypted: this.props.defaultEncrypted ?? privateShouldBeEncrypted(), + useMls: false, joinRule, name: this.props.defaultName || "", topic: "", @@ -107,6 +109,7 @@ export default class CreateRoomDialog extends React.Component { } 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.useMls = this.state.useMls; } if (this.state.topic) { @@ -188,6 +191,10 @@ export default class CreateRoomDialog extends React.Component { this.setState({ isEncrypted }); }; + private onUseMlsChange = (useMls: boolean): void => { + this.setState({ useMls }); + }; + private onAliasChange = (alias: string): void => { this.setState({ alias }); }; @@ -311,6 +318,19 @@ export default class CreateRoomDialog extends React.Component { ); } + let mlsSection: JSX.Element; + if (this.state.isEncrypted) { + mlsSection = ( + + +

Experimental! Don't do it!

+
+ ); + } let federateLabel = _t( "You might enable this if the room will only be used for collaborating with internal " + @@ -374,6 +394,7 @@ export default class CreateRoomDialog extends React.Component { {this.state.detailsOpen ? _t("Hide advanced") : _t("Show advanced")} + {mlsSection} { type: "m.room.encryption", state_key: "", content: { - algorithm: "m.megolm.v1.aes-sha2", + algorithm: opts.useMls ? MLS_ALGORITHM.name : "m.megolm.v1.aes-sha2", }, }); } @@ -315,6 +317,14 @@ export default async function createRoom(opts: IOpts): Promise { if (opts.dmUserId) await Rooms.setDMRoom(roomId, opts.dmUserId); }) + .then(async () => { + if (opts.encryption && opts.useMls) { + return await client.crypto.mlsProvider.createGroup( + await room, + createOpts.invite || [], + ); + } + }) .then(() => { if (opts.parentSpace) { return SpaceStore.instance.addRoomToSpace(