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

Add room intro warning when e2ee is not enabled #5929

Merged
merged 8 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions res/css/views/rooms/_NewRoomIntro.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,24 @@ limitations under the License.
font-size: $font-15px;
color: $secondary-fg-color;
}

.mx_NewRoomIntro_message:not(:first-child) {
padding-top: 1em;
margin-top: 1em;
border-top: 1px solid currentColor;
}

.mx_NewRoomIntro_message[role=alert]::before {
--size: 25px;
content: "!";
float: left;
border-radius: 50%;
width: var(--size);
height: var(--size);
line-height: var(--size);
text-align: center;
background: $button-danger-bg-color;
color: #fff;
margin-right: calc(var(--size) / 2);
}
}
20 changes: 20 additions & 0 deletions src/components/views/rooms/NewRoomIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ import dis from "../../../dispatcher/dispatcher";
import SpaceStore from "../../../stores/SpaceStore";
import {showSpaceInvite} from "../../../utils/space";

import { privateShouldBeEncrypted } from "../../../createRoom";

function hasExpectedEncryptionSettings(room): boolean {
const isEncrypted: boolean = room._client.isRoomEncrypted(room.roomId);
const isPublic: boolean = room.getJoinRule() === "public";
return isPublic || !privateShouldBeEncrypted() || isEncrypted;
}

const NewRoomIntro = () => {
const cli = useContext(MatrixClientContext);
const {room, roomId} = useContext(RoomContext);
Expand Down Expand Up @@ -168,6 +176,18 @@ const NewRoomIntro = () => {

return <div className="mx_NewRoomIntro">
{ body }

{ !hasExpectedEncryptionSettings(room) && <p className="mx_NewRoomIntro_message" role="alert">
{_t("Messages in this room are not end-to-end encrypted. " +
"Messages sent in an unencrypted room can be seen by the server and third parties. " +
"<a>Learn more about encryption.</a>", {},
{
a: sub => <a href="https://element.io/help#encryption"
rel="noreferrer noopener" target="_blank"
>{sub}</a>,
})}

</p>}
</div>;
};

Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,7 @@
"Invite to just this room": "Invite to just this room",
"Add a photo, so people can easily spot your room.": "Add a photo, so people can easily spot your room.",
"This is the start of <roomName/>.": "This is the start of <roomName/>.",
"Messages in this room are not end-to-end encrypted. Messages sent in an unencrypted room can be seen by the server and third parties. <a>Learn more about encryption.</a>": "Messages in this room are not end-to-end encrypted. Messages sent in an unencrypted room can be seen by the server and third parties. <a>Learn more about encryption.</a>",
"No pinned messages.": "No pinned messages.",
"Loading...": "Loading...",
"Pinned Messages": "Pinned Messages",
Expand Down