diff --git a/res/css/_common.scss b/res/css/_common.scss index ae565d2fe81..d01532a4a2a 100644 --- a/res/css/_common.scss +++ b/res/css/_common.scss @@ -381,6 +381,11 @@ input[type=text]:focus, input[type=password]:focus, textarea:focus { font-size: $font-14px; color: $primary-fg-color; word-wrap: break-word; + + a { + color: $accent-color; + cursor: pointer; + } } .mx_Dialog_buttons { diff --git a/src/components/views/dialogs/CreateRoomDialog.tsx b/src/components/views/dialogs/CreateRoomDialog.tsx index d573882f403..0da5f189bfe 100644 --- a/src/components/views/dialogs/CreateRoomDialog.tsx +++ b/src/components/views/dialogs/CreateRoomDialog.tsx @@ -39,11 +39,13 @@ interface IProps { defaultPublic?: boolean; defaultName?: string; parentSpace?: Room; + defaultEncrypted?: boolean; onFinished(proceed: boolean, opts?: IOpts): void; } interface IState { joinRule: JoinRule; + isPublic: boolean; isEncrypted: boolean; name: string; topic: string; @@ -74,8 +76,9 @@ export default class CreateRoomDialog extends React.Component { const config = SdkConfig.get(); this.state = { + isPublic: this.props.defaultPublic || false, + isEncrypted: this.props.defaultEncrypted ?? privateShouldBeEncrypted(), joinRule, - isEncrypted: privateShouldBeEncrypted(), name: this.props.defaultName || "", topic: "", alias: "", diff --git a/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx b/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx index ede9a5ddb59..d9e97d570b0 100644 --- a/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx +++ b/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx @@ -37,6 +37,8 @@ import RoomUpgradeWarningDialog from '../../../dialogs/RoomUpgradeWarningDialog' import { upgradeRoom } from "../../../../../utils/RoomUpgrade"; import { arrayHasDiff } from "../../../../../utils/arrays"; import SettingsFlag from '../../../elements/SettingsFlag'; +import createRoom, { IOpts } from '../../../../../createRoom'; +import CreateRoomDialog from '../../../dialogs/CreateRoomDialog'; interface IProps { roomId: string; @@ -129,7 +131,38 @@ export default class SecurityRoomSettingsTab extends React.Component { + private onEncryptionChange = async () => { + if (this.state.joinRule == "public") { + const dialog = Modal.createTrackedDialog('Confirm Public Encrypted Room', '', QuestionDialog, { + title: _t('Are you sure you want to add encryption to this public room?'), + description:
+

{ _t( + "It's not recommended to add encryption to public rooms." + + "Anyone can find and join public rooms, so anyone can read messages in them. " + + "You'll get none of the benefits of encryption, and you won't be able to turn it " + + "off later. Encrypting messages in a public room will make receiving and sending " + + "messages slower.", + null, + { "b": (sub) => { sub } }, + ) }

+

{ _t( + "To avoid these issues, create a new encrypted room for " + + "the conversation you plan to have.", + null, + { "a": (sub) => { + dialog.close(); + this.createNewRoom(false, true); + }}> { sub } }, + ) }

+
, + + }); + + const { finished } = dialog; + const [confirm] = await finished; + if (!confirm) return; + } + Modal.createTrackedDialog('Enable encryption', '', QuestionDialog, { title: _t('Enable encryption?'), description: _t( @@ -194,6 +227,41 @@ export default class SecurityRoomSettingsTab extends React.Component +

{ _t( + "It's not recommended to make encrypted rooms public. " + + "It will mean anyone can find and join the room, so anyone can read messages. " + + "You'll get none of the benefits of encryption. Encrypting messages in a public " + + "room will make receiving and sending messages slower.", + null, + { "b": (sub) => { sub } }, + ) }

+

{ _t( + "To avoid these issues, create a new public room for the conversation " + + "you plan to have.", + null, + { + "a": (sub) => { + dialog.close(); + this.createNewRoom(true, false); + }}> { sub } , + }, + ) }

+ , + }); + + const { finished } = dialog; + const [confirm] = await finished; + if (!confirm) return; + } + if (beforeJoinRule === joinRule && !restrictedAllowRoomIds) return; const content: IContent = { @@ -254,6 +322,20 @@ export default class SecurityRoomSettingsTab extends React.Component { + const modal = Modal.createTrackedDialog<[boolean, IOpts]>( + "Create Room", + "Create room after trying to make an E2EE room public", + CreateRoomDialog, + { defaultPublic, defaultEncrypted }, + ); + const [shouldCreate, opts] = await modal.finished; + if (shouldCreate) { + await createRoom(opts); + } + return shouldCreate; + }; + private onHistoryRadioToggle = (history: HistoryVisibility) => { const beforeHistory = this.state.history; if (beforeHistory === history) return; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 7fea360c1be..b9a6b5e04c4 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1450,9 +1450,15 @@ "Send %(eventType)s events": "Send %(eventType)s events", "Permissions": "Permissions", "Select the roles required to change various parts of the room": "Select the roles required to change various parts of the room", + "Are you sure you want to add encryption to this public room?": "Are you sure you want to add encryption to this public room?", + "It's not recommended to add encryption to public rooms.Anyone can find and join public rooms, so anyone can read messages in them. You'll get none of the benefits of encryption, and you won't be able to turn it off later. Encrypting messages in a public room will make receiving and sending messages slower.": "It's not recommended to add encryption to public rooms.Anyone can find and join public rooms, so anyone can read messages in them. You'll get none of the benefits of encryption, and you won't be able to turn it off later. Encrypting messages in a public room will make receiving and sending messages slower.", + "To avoid these issues, create a new encrypted room for the conversation you plan to have.": "To avoid these issues, create a new encrypted room for the conversation you plan to have.", "Enable encryption?": "Enable encryption?", "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted room cannot be seen by the server, only by the participants of the room. Enabling encryption may prevent many bots and bridges from working correctly. Learn more about encryption.": "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted room cannot be seen by the server, only by the participants of the room. Enabling encryption may prevent many bots and bridges from working correctly. Learn more about encryption.", "This upgrade will allow members of selected spaces access to this room without an invite.": "This upgrade will allow members of selected spaces access to this room without an invite.", + "Are you sure you want to make this encrypted room public?": "Are you sure you want to make this encrypted room public?", + "It's not recommended to make encrypted rooms public. It will mean anyone can find and join the room, so anyone can read messages. You'll get none of the benefits of encryption. Encrypting messages in a public room will make receiving and sending messages slower.": "It's not recommended to make encrypted rooms public. It will mean anyone can find and join the room, so anyone can read messages. You'll get none of the benefits of encryption. Encrypting messages in a public room will make receiving and sending messages slower.", + "To avoid these issues, create a new public room for the conversation you plan to have.": "To avoid these issues, create a new public room for the conversation you plan to have.", "To link to this room, please add an address.": "To link to this room, please add an address.", "Private (invite only)": "Private (invite only)", "Only invited people can join.": "Only invited people can join.",