2019-01-30 00:30:53 +03:00
|
|
|
/*
|
2021-04-06 14:26:50 +03:00
|
|
|
Copyright 2019-2021 The Matrix.org Foundation C.I.C.
|
2019-01-30 00:30:53 +03:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
2021-04-27 13:56:45 +03:00
|
|
|
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
2019-02-22 20:47:18 +03:00
|
|
|
import {_t} from "../../../../../languageHandler";
|
2019-12-21 00:13:46 +03:00
|
|
|
import {MatrixClientPeg} from "../../../../../MatrixClientPeg";
|
2019-12-20 04:19:56 +03:00
|
|
|
import * as sdk from "../../../../..";
|
2019-02-22 20:47:18 +03:00
|
|
|
import LabelledToggleSwitch from "../../../elements/LabelledToggleSwitch";
|
2019-03-01 06:34:34 +03:00
|
|
|
import Modal from "../../../../../Modal";
|
|
|
|
import QuestionDialog from "../../../dialogs/QuestionDialog";
|
2020-07-28 19:13:58 +03:00
|
|
|
import StyledRadioGroup from '../../../elements/StyledRadioGroup';
|
2020-07-28 20:53:43 +03:00
|
|
|
import {SettingLevel} from "../../../../../settings/SettingLevel";
|
2020-09-18 20:33:02 +03:00
|
|
|
import SettingsStore from "../../../../../settings/SettingsStore";
|
2020-10-28 04:20:25 +03:00
|
|
|
import {UIFeature} from "../../../../../settings/UIFeature";
|
2021-04-06 14:26:50 +03:00
|
|
|
import { replaceableComponent } from "../../../../../utils/replaceableComponent";
|
2019-01-30 00:30:53 +03:00
|
|
|
|
2021-04-26 18:20:16 +03:00
|
|
|
// Knock and private are reserved keywords which are not yet implemented.
|
2021-06-08 18:33:47 +03:00
|
|
|
export enum JoinRule {
|
2021-04-26 18:14:21 +03:00
|
|
|
Public = "public",
|
|
|
|
Knock = "knock",
|
|
|
|
Invite = "invite",
|
|
|
|
Private = "private",
|
|
|
|
}
|
|
|
|
|
2021-06-08 18:33:47 +03:00
|
|
|
export enum GuestAccess {
|
2021-04-26 18:14:21 +03:00
|
|
|
CanJoin = "can_join",
|
|
|
|
Forbidden = "forbidden",
|
|
|
|
}
|
|
|
|
|
2021-06-08 18:33:47 +03:00
|
|
|
export enum HistoryVisibility {
|
2021-04-26 18:14:21 +03:00
|
|
|
Invited = "invited",
|
|
|
|
Joined = "joined",
|
|
|
|
Shared = "shared",
|
|
|
|
WorldReadable = "world_readable",
|
|
|
|
}
|
2021-04-06 14:26:50 +03:00
|
|
|
|
|
|
|
interface IProps {
|
|
|
|
roomId: string;
|
|
|
|
}
|
2019-01-30 00:30:53 +03:00
|
|
|
|
2021-04-06 14:26:50 +03:00
|
|
|
interface IState {
|
|
|
|
joinRule: JoinRule;
|
|
|
|
guestAccess: GuestAccess;
|
2021-04-26 16:08:45 +03:00
|
|
|
history: HistoryVisibility;
|
2021-04-06 14:26:50 +03:00
|
|
|
hasAliases: boolean;
|
|
|
|
encrypted: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
@replaceableComponent("views.settings.tabs.room.SecurityRoomSettingsTab")
|
|
|
|
export default class SecurityRoomSettingsTab extends React.Component<IProps, IState> {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2019-02-08 00:01:34 +03:00
|
|
|
|
|
|
|
this.state = {
|
2021-04-26 18:14:21 +03:00
|
|
|
joinRule: JoinRule.Invite,
|
|
|
|
guestAccess: GuestAccess.CanJoin,
|
|
|
|
history: HistoryVisibility.Shared,
|
2020-02-19 13:18:56 +03:00
|
|
|
hasAliases: false,
|
2019-02-08 00:01:34 +03:00
|
|
|
encrypted: false,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-03-31 23:12:52 +03:00
|
|
|
// TODO: [REACT-WARNING] Move this to constructor
|
2021-04-27 13:56:45 +03:00
|
|
|
async UNSAFE_componentWillMount() { // eslint-disable-line camelcase
|
2021-04-26 16:02:53 +03:00
|
|
|
MatrixClientPeg.get().on("RoomState.events", this.onStateEvent);
|
2019-02-08 00:01:34 +03:00
|
|
|
|
|
|
|
const room = MatrixClientPeg.get().getRoom(this.props.roomId);
|
|
|
|
const state = room.currentState;
|
2019-02-14 21:09:37 +03:00
|
|
|
|
2021-04-26 16:02:53 +03:00
|
|
|
const joinRule: JoinRule = this.pullContentPropertyFromEvent(
|
2019-02-14 21:09:37 +03:00
|
|
|
state.getStateEvents("m.room.join_rules", ""),
|
|
|
|
'join_rule',
|
2021-04-27 13:56:45 +03:00
|
|
|
JoinRule.Invite,
|
2019-02-14 21:09:37 +03:00
|
|
|
);
|
2021-04-26 16:02:53 +03:00
|
|
|
const guestAccess: GuestAccess = this.pullContentPropertyFromEvent(
|
2019-02-14 21:09:37 +03:00
|
|
|
state.getStateEvents("m.room.guest_access", ""),
|
|
|
|
'guest_access',
|
2021-04-27 13:56:45 +03:00
|
|
|
GuestAccess.Forbidden,
|
2019-02-14 21:09:37 +03:00
|
|
|
);
|
2021-04-26 16:08:45 +03:00
|
|
|
const history: HistoryVisibility = this.pullContentPropertyFromEvent(
|
2019-02-14 21:09:37 +03:00
|
|
|
state.getStateEvents("m.room.history_visibility", ""),
|
|
|
|
'history_visibility',
|
2021-04-27 13:56:45 +03:00
|
|
|
HistoryVisibility.Shared,
|
2019-02-14 21:09:37 +03:00
|
|
|
);
|
2019-02-08 00:01:34 +03:00
|
|
|
const encrypted = MatrixClientPeg.get().isRoomEncrypted(this.props.roomId);
|
|
|
|
this.setState({joinRule, guestAccess, history, encrypted});
|
2021-04-26 16:02:53 +03:00
|
|
|
const hasAliases = await this.hasAliases();
|
2020-02-19 13:18:56 +03:00
|
|
|
this.setState({hasAliases});
|
2019-01-30 00:30:53 +03:00
|
|
|
}
|
|
|
|
|
2021-04-27 13:56:45 +03:00
|
|
|
private pullContentPropertyFromEvent<T>(event: MatrixEvent, key: string, defaultValue: T): T {
|
2019-02-14 21:09:37 +03:00
|
|
|
if (!event || !event.getContent()) return defaultValue;
|
|
|
|
return event.getContent()[key] || defaultValue;
|
|
|
|
}
|
|
|
|
|
2021-04-27 13:56:45 +03:00
|
|
|
componentWillUnmount() {
|
2021-04-26 16:02:53 +03:00
|
|
|
MatrixClientPeg.get().removeListener("RoomState.events", this.onStateEvent);
|
2019-01-30 00:30:53 +03:00
|
|
|
}
|
|
|
|
|
2021-04-27 13:56:45 +03:00
|
|
|
private onStateEvent = (e: MatrixEvent) => {
|
2019-02-02 00:56:29 +03:00
|
|
|
const refreshWhenTypes = [
|
|
|
|
'm.room.join_rules',
|
|
|
|
'm.room.guest_access',
|
|
|
|
'm.room.history_visibility',
|
|
|
|
'm.room.encryption',
|
|
|
|
];
|
2019-01-30 00:30:53 +03:00
|
|
|
if (refreshWhenTypes.includes(e.getType())) this.forceUpdate();
|
|
|
|
};
|
|
|
|
|
2021-06-08 18:40:01 +03:00
|
|
|
private onEncryptionChange = () => {
|
2019-03-01 06:34:34 +03:00
|
|
|
Modal.createTrackedDialog('Enable encryption', '', QuestionDialog, {
|
|
|
|
title: _t('Enable encryption?'),
|
|
|
|
description: _t(
|
|
|
|
"Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted " +
|
2019-03-01 06:45:31 +03:00
|
|
|
"room cannot be seen by the server, only by the participants of the room. Enabling encryption " +
|
2019-03-01 06:34:34 +03:00
|
|
|
"may prevent many bots and bridges from working correctly. <a>Learn more about encryption.</a>",
|
|
|
|
{},
|
|
|
|
{
|
2021-04-23 20:11:54 +03:00
|
|
|
a: sub => <a href="https://element.io/help#encryption"
|
|
|
|
rel="noreferrer noopener" target="_blank"
|
|
|
|
>{sub}</a>,
|
2019-03-01 06:34:34 +03:00
|
|
|
},
|
|
|
|
),
|
|
|
|
onFinished: (confirm) => {
|
|
|
|
if (!confirm) {
|
|
|
|
this.setState({encrypted: false});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const beforeEncrypted = this.state.encrypted;
|
|
|
|
this.setState({encrypted: true});
|
|
|
|
MatrixClientPeg.get().sendStateEvent(
|
|
|
|
this.props.roomId, "m.room.encryption",
|
|
|
|
{ algorithm: "m.megolm.v1.aes-sha2" },
|
|
|
|
).catch((e) => {
|
|
|
|
console.error(e);
|
|
|
|
this.setState({encrypted: beforeEncrypted});
|
|
|
|
});
|
|
|
|
},
|
2019-02-08 00:01:34 +03:00
|
|
|
});
|
2019-01-30 00:30:53 +03:00
|
|
|
};
|
|
|
|
|
2021-04-27 13:56:45 +03:00
|
|
|
private fixGuestAccess = (e: React.MouseEvent) => {
|
2019-01-30 00:30:53 +03:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
2021-04-26 18:14:21 +03:00
|
|
|
const joinRule = JoinRule.Invite;
|
|
|
|
const guestAccess = GuestAccess.CanJoin;
|
2019-02-08 00:01:34 +03:00
|
|
|
|
|
|
|
const beforeJoinRule = this.state.joinRule;
|
|
|
|
const beforeGuestAccess = this.state.guestAccess;
|
|
|
|
this.setState({joinRule, guestAccess});
|
|
|
|
|
2019-01-30 00:30:53 +03:00
|
|
|
const client = MatrixClientPeg.get();
|
2019-02-08 00:01:34 +03:00
|
|
|
client.sendStateEvent(this.props.roomId, "m.room.join_rules", {join_rule: joinRule}, "").catch((e) => {
|
|
|
|
console.error(e);
|
|
|
|
this.setState({joinRule: beforeJoinRule});
|
|
|
|
});
|
|
|
|
client.sendStateEvent(this.props.roomId, "m.room.guest_access", {guest_access: guestAccess}, "").catch((e) => {
|
|
|
|
console.error(e);
|
|
|
|
this.setState({guestAccess: beforeGuestAccess});
|
|
|
|
});
|
2019-01-30 00:30:53 +03:00
|
|
|
};
|
|
|
|
|
2021-04-27 13:56:45 +03:00
|
|
|
private onRoomAccessRadioToggle = (roomAccess: string) => {
|
2019-01-30 00:30:53 +03:00
|
|
|
// join_rule
|
|
|
|
// INVITE | PUBLIC
|
|
|
|
// ----------------------+----------------
|
|
|
|
// guest CAN_JOIN | inv_only | pub_with_guest
|
|
|
|
// access ----------------------+----------------
|
|
|
|
// FORBIDDEN | inv_only | pub_no_guest
|
|
|
|
// ----------------------+----------------
|
|
|
|
|
|
|
|
// we always set guests can_join here as it makes no sense to have
|
|
|
|
// an invite-only room that guests can't join. If you explicitly
|
|
|
|
// invite them, you clearly want them to join, whether they're a
|
|
|
|
// guest or not. In practice, guest_access should probably have
|
|
|
|
// been implemented as part of the join_rules enum.
|
2021-04-26 18:14:21 +03:00
|
|
|
let joinRule = JoinRule.Invite;
|
|
|
|
let guestAccess = GuestAccess.CanJoin;
|
2019-01-30 00:30:53 +03:00
|
|
|
|
2020-08-05 15:53:19 +03:00
|
|
|
switch (roomAccess) {
|
2019-01-30 00:30:53 +03:00
|
|
|
case "invite_only":
|
|
|
|
// no change - use defaults above
|
|
|
|
break;
|
|
|
|
case "public_no_guests":
|
2021-04-26 18:14:21 +03:00
|
|
|
joinRule = JoinRule.Public;
|
|
|
|
guestAccess = GuestAccess.Forbidden;
|
2019-01-30 00:30:53 +03:00
|
|
|
break;
|
|
|
|
case "public_with_guests":
|
2021-04-26 18:14:21 +03:00
|
|
|
joinRule = JoinRule.Public;
|
|
|
|
guestAccess = GuestAccess.CanJoin;
|
2019-01-30 00:30:53 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-02-08 00:01:34 +03:00
|
|
|
const beforeJoinRule = this.state.joinRule;
|
|
|
|
const beforeGuestAccess = this.state.guestAccess;
|
|
|
|
this.setState({joinRule, guestAccess});
|
|
|
|
|
2019-01-30 00:30:53 +03:00
|
|
|
const client = MatrixClientPeg.get();
|
2019-02-08 00:01:34 +03:00
|
|
|
client.sendStateEvent(this.props.roomId, "m.room.join_rules", {join_rule: joinRule}, "").catch((e) => {
|
|
|
|
console.error(e);
|
|
|
|
this.setState({joinRule: beforeJoinRule});
|
|
|
|
});
|
|
|
|
client.sendStateEvent(this.props.roomId, "m.room.guest_access", {guest_access: guestAccess}, "").catch((e) => {
|
|
|
|
console.error(e);
|
|
|
|
this.setState({guestAccess: beforeGuestAccess});
|
|
|
|
});
|
2019-01-30 00:30:53 +03:00
|
|
|
};
|
|
|
|
|
2021-04-27 13:56:45 +03:00
|
|
|
private onHistoryRadioToggle = (history: HistoryVisibility) => {
|
2019-02-08 00:01:34 +03:00
|
|
|
const beforeHistory = this.state.history;
|
2020-08-05 15:53:19 +03:00
|
|
|
this.setState({history: history});
|
2019-01-30 00:30:53 +03:00
|
|
|
MatrixClientPeg.get().sendStateEvent(this.props.roomId, "m.room.history_visibility", {
|
2020-08-05 15:53:19 +03:00
|
|
|
history_visibility: history,
|
2019-02-08 00:01:34 +03:00
|
|
|
}, "").catch((e) => {
|
|
|
|
console.error(e);
|
|
|
|
this.setState({history: beforeHistory});
|
|
|
|
});
|
2019-01-30 00:30:53 +03:00
|
|
|
};
|
|
|
|
|
2021-04-27 13:56:45 +03:00
|
|
|
private updateBlacklistDevicesFlag = (checked: boolean) => {
|
2019-03-22 23:22:20 +03:00
|
|
|
MatrixClientPeg.get().getRoom(this.props.roomId).setBlacklistUnverifiedDevices(checked);
|
|
|
|
};
|
|
|
|
|
2021-04-27 13:56:45 +03:00
|
|
|
private async hasAliases(): Promise<boolean> {
|
2020-02-19 13:18:56 +03:00
|
|
|
const cli = MatrixClientPeg.get();
|
|
|
|
if (await cli.doesServerSupportUnstableFeature("org.matrix.msc2432")) {
|
|
|
|
const response = await cli.unstableGetLocalAliases(this.props.roomId);
|
|
|
|
const localAliases = response.aliases;
|
|
|
|
return Array.isArray(localAliases) && localAliases.length !== 0;
|
|
|
|
} else {
|
|
|
|
const room = cli.getRoom(this.props.roomId);
|
|
|
|
const aliasEvents = room.currentState.getStateEvents("m.room.aliases") || [];
|
|
|
|
const hasAliases = !!aliasEvents.find((ev) => (ev.getContent().aliases || []).length > 0);
|
|
|
|
return hasAliases;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-26 16:02:53 +03:00
|
|
|
private renderRoomAccess() {
|
2019-01-30 00:30:53 +03:00
|
|
|
const client = MatrixClientPeg.get();
|
|
|
|
const room = client.getRoom(this.props.roomId);
|
2019-02-08 00:01:34 +03:00
|
|
|
const joinRule = this.state.joinRule;
|
|
|
|
const guestAccess = this.state.guestAccess;
|
2019-01-30 00:30:53 +03:00
|
|
|
|
|
|
|
const canChangeAccess = room.currentState.mayClientSendStateEvent("m.room.join_rules", client)
|
|
|
|
&& room.currentState.mayClientSendStateEvent("m.room.guest_access", client);
|
|
|
|
|
|
|
|
let guestWarning = null;
|
|
|
|
if (joinRule !== 'public' && guestAccess === 'forbidden') {
|
|
|
|
guestWarning = (
|
|
|
|
<div className='mx_SecurityRoomSettingsTab_warning'>
|
2019-02-22 20:47:18 +03:00
|
|
|
<img src={require("../../../../../../res/img/warning.svg")} width={15} height={15} />
|
2019-01-30 00:30:53 +03:00
|
|
|
<span>
|
|
|
|
{_t("Guests cannot join this room even if explicitly invited.")}
|
2021-04-26 16:02:53 +03:00
|
|
|
<a href="" onClick={this.fixGuestAccess}>{_t("Click here to fix")}</a>
|
2019-01-30 00:30:53 +03:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
let aliasWarning = null;
|
2020-02-19 13:18:56 +03:00
|
|
|
if (joinRule === 'public' && !this.state.hasAliases) {
|
2019-01-30 00:30:53 +03:00
|
|
|
aliasWarning = (
|
|
|
|
<div className='mx_SecurityRoomSettingsTab_warning'>
|
2019-02-22 20:47:18 +03:00
|
|
|
<img src={require("../../../../../../res/img/warning.svg")} width={15} height={15} />
|
2019-01-30 00:30:53 +03:00
|
|
|
<span>
|
2020-04-14 12:06:57 +03:00
|
|
|
{_t("To link to this room, please add an address.")}
|
2019-01-30 00:30:53 +03:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
{guestWarning}
|
|
|
|
{aliasWarning}
|
2020-07-28 19:13:58 +03:00
|
|
|
<StyledRadioGroup
|
|
|
|
name="roomVis"
|
|
|
|
value={joinRule}
|
2021-04-26 16:02:53 +03:00
|
|
|
onChange={this.onRoomAccessRadioToggle}
|
2020-07-28 19:13:58 +03:00
|
|
|
definitions={[
|
|
|
|
{
|
|
|
|
value: "invite_only",
|
|
|
|
disabled: !canChangeAccess,
|
|
|
|
label: _t('Only people who have been invited'),
|
|
|
|
checked: joinRule !== "public",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: "public_no_guests",
|
|
|
|
disabled: !canChangeAccess,
|
|
|
|
label: _t('Anyone who knows the room\'s link, apart from guests'),
|
|
|
|
checked: joinRule === "public" && guestAccess !== "can_join",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: "public_with_guests",
|
|
|
|
disabled: !canChangeAccess,
|
|
|
|
label: _t("Anyone who knows the room's link, including guests"),
|
|
|
|
checked: joinRule === "public" && guestAccess === "can_join",
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
2019-01-30 00:30:53 +03:00
|
|
|
</div>
|
2019-01-30 00:37:21 +03:00
|
|
|
);
|
2019-01-30 00:30:53 +03:00
|
|
|
}
|
|
|
|
|
2021-04-26 16:02:53 +03:00
|
|
|
private renderHistory() {
|
2019-01-30 00:30:53 +03:00
|
|
|
const client = MatrixClientPeg.get();
|
2019-02-08 00:01:34 +03:00
|
|
|
const history = this.state.history;
|
|
|
|
const state = client.getRoom(this.props.roomId).currentState;
|
2019-01-30 00:30:53 +03:00
|
|
|
const canChangeHistory = state.mayClientSendStateEvent('m.room.history_visibility', client);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
{_t('Changes to who can read history will only apply to future messages in this room. ' +
|
|
|
|
'The visibility of existing history will be unchanged.')}
|
|
|
|
</div>
|
2020-07-28 19:13:58 +03:00
|
|
|
<StyledRadioGroup
|
|
|
|
name="historyVis"
|
|
|
|
value={history}
|
2021-04-26 16:02:53 +03:00
|
|
|
onChange={this.onHistoryRadioToggle}
|
2020-07-28 19:13:58 +03:00
|
|
|
definitions={[
|
|
|
|
{
|
2021-04-27 13:56:45 +03:00
|
|
|
value: HistoryVisibility.WorldReadable,
|
2020-07-28 19:13:58 +03:00
|
|
|
disabled: !canChangeHistory,
|
|
|
|
label: _t("Anyone"),
|
|
|
|
},
|
|
|
|
{
|
2021-04-27 13:56:45 +03:00
|
|
|
value: HistoryVisibility.Shared,
|
2020-07-28 19:13:58 +03:00
|
|
|
disabled: !canChangeHistory,
|
|
|
|
label: _t('Members only (since the point in time of selecting this option)'),
|
|
|
|
},
|
|
|
|
{
|
2021-04-27 13:56:45 +03:00
|
|
|
value: HistoryVisibility.Invited,
|
2020-07-28 19:13:58 +03:00
|
|
|
disabled: !canChangeHistory,
|
|
|
|
label: _t('Members only (since they were invited)'),
|
|
|
|
},
|
|
|
|
{
|
2021-04-27 13:56:45 +03:00
|
|
|
value: HistoryVisibility.Joined,
|
2020-07-28 19:13:58 +03:00
|
|
|
disabled: !canChangeHistory,
|
|
|
|
label: _t('Members only (since they joined)'),
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
2019-01-30 00:30:53 +03:00
|
|
|
</div>
|
2019-01-30 00:37:21 +03:00
|
|
|
);
|
2019-01-30 00:30:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const SettingsFlag = sdk.getComponent("elements.SettingsFlag");
|
|
|
|
|
|
|
|
const client = MatrixClientPeg.get();
|
|
|
|
const room = client.getRoom(this.props.roomId);
|
2019-02-08 00:01:34 +03:00
|
|
|
const isEncrypted = this.state.encrypted;
|
2019-01-30 00:30:53 +03:00
|
|
|
const hasEncryptionPermission = room.currentState.mayClientSendStateEvent("m.room.encryption", client);
|
|
|
|
const canEnableEncryption = !isEncrypted && hasEncryptionPermission;
|
|
|
|
|
|
|
|
let encryptionSettings = null;
|
2020-09-18 20:33:02 +03:00
|
|
|
if (isEncrypted && SettingsStore.isEnabled("blacklistUnverifiedDevices")) {
|
|
|
|
encryptionSettings = <SettingsFlag
|
|
|
|
name="blacklistUnverifiedDevices"
|
|
|
|
level={SettingLevel.ROOM_DEVICE}
|
2021-04-26 16:02:53 +03:00
|
|
|
onChange={this.updateBlacklistDevicesFlag}
|
2020-09-18 20:33:02 +03:00
|
|
|
roomId={this.props.roomId}
|
|
|
|
/>;
|
2019-01-30 00:30:53 +03:00
|
|
|
}
|
|
|
|
|
2020-10-28 04:20:25 +03:00
|
|
|
let historySection = (<>
|
|
|
|
<span className='mx_SettingsTab_subheading'>{_t("Who can read history?")}</span>
|
|
|
|
<div className='mx_SettingsTab_section mx_SettingsTab_subsectionText'>
|
2021-04-26 16:02:53 +03:00
|
|
|
{this.renderHistory()}
|
2020-10-28 04:20:25 +03:00
|
|
|
</div>
|
|
|
|
</>);
|
|
|
|
if (!SettingsStore.getValue(UIFeature.RoomHistorySettings)) {
|
|
|
|
historySection = null;
|
|
|
|
}
|
|
|
|
|
2019-01-30 00:30:53 +03:00
|
|
|
return (
|
|
|
|
<div className="mx_SettingsTab mx_SecurityRoomSettingsTab">
|
|
|
|
<div className="mx_SettingsTab_heading">{_t("Security & Privacy")}</div>
|
|
|
|
|
|
|
|
<span className='mx_SettingsTab_subheading'>{_t("Encryption")}</span>
|
|
|
|
<div className='mx_SettingsTab_section mx_SecurityRoomSettingsTab_encryptionSection'>
|
2019-01-30 00:37:21 +03:00
|
|
|
<div>
|
|
|
|
<div className='mx_SettingsTab_subsectionText'>
|
|
|
|
<span>{_t("Once enabled, encryption cannot be disabled.")}</span>
|
|
|
|
</div>
|
2021-04-26 16:02:53 +03:00
|
|
|
<LabelledToggleSwitch value={isEncrypted} onChange={this.onEncryptionChange}
|
2021-04-23 20:11:54 +03:00
|
|
|
label={_t("Encrypted")} disabled={!canEnableEncryption}
|
|
|
|
/>
|
2019-01-30 00:37:21 +03:00
|
|
|
</div>
|
2019-01-30 00:30:53 +03:00
|
|
|
{encryptionSettings}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<span className='mx_SettingsTab_subheading'>{_t("Who can access this room?")}</span>
|
|
|
|
<div className='mx_SettingsTab_section mx_SettingsTab_subsectionText'>
|
2021-04-26 16:02:53 +03:00
|
|
|
{this.renderRoomAccess()}
|
2019-01-30 00:30:53 +03:00
|
|
|
</div>
|
|
|
|
|
2020-10-28 04:20:25 +03:00
|
|
|
{historySection}
|
2019-01-30 00:30:53 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|