update UrlPreview settings to be more privacy-aware in e2ee rooms
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
df58715a17
commit
891070d001
2 changed files with 68 additions and 30 deletions
|
@ -618,10 +618,26 @@ module.exports = React.createClass({
|
|||
}
|
||||
},
|
||||
|
||||
_updatePreviewUrlVisibility: function(room) {
|
||||
this.setState({
|
||||
showUrlPreview: SettingsStore.getValue("urlPreviewsEnabled", room.roomId),
|
||||
});
|
||||
_updatePreviewUrlVisibility: function({roomId}) {
|
||||
const levels = [
|
||||
SettingLevel.ROOM_DEVICE,
|
||||
SettingLevel.ROOM_ACCOUNT,
|
||||
];
|
||||
let showUrlPreview;
|
||||
if (MatrixClientPeg.get().isRoomEncrypted(roomId)) {
|
||||
for (const level of levels) {
|
||||
const value = SettingsStore.getValueAt(level, "urlPreviewsEnabled", roomId, true, true);
|
||||
if (value === Boolean(value)) { // if is Boolean
|
||||
showUrlPreview = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
showUrlPreview = showUrlPreview || false;
|
||||
} else {
|
||||
showUrlPreview = SettingsStore.getValue("urlPreviewsEnabled", roomId);
|
||||
}
|
||||
this.setState({showUrlPreview});
|
||||
},
|
||||
|
||||
onRoom: function(room) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
Copyright 2016 OpenMarket Ltd
|
||||
Copyright 2017 Travis Ralston
|
||||
Copyright 2018 New Vector Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -15,6 +16,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import {MatrixClient} from "matrix-js-sdk";
|
||||
const React = require('react');
|
||||
import PropTypes from 'prop-types';
|
||||
const sdk = require("../../../index");
|
||||
|
@ -29,6 +31,10 @@ module.exports = React.createClass({
|
|||
room: PropTypes.object,
|
||||
},
|
||||
|
||||
contextTypes: {
|
||||
matrixClient: PropTypes.instanceOf(MatrixClient).isRequired,
|
||||
},
|
||||
|
||||
saveSettings: function() {
|
||||
const promises = [];
|
||||
if (this.refs.urlPreviewsRoom) promises.push(this.refs.urlPreviewsRoom.save());
|
||||
|
@ -39,19 +45,29 @@ module.exports = React.createClass({
|
|||
render: function() {
|
||||
const SettingsFlag = sdk.getComponent("elements.SettingsFlag");
|
||||
const roomId = this.props.room.roomId;
|
||||
const isEncrypted = this.context.matrixClient.isRoomEncrypted(roomId);
|
||||
|
||||
let previewsForAccount = null;
|
||||
if (SettingsStore.getValueAt(SettingLevel.ACCOUNT, "urlPreviewsEnabled")) {
|
||||
let previewsForRoom = null;
|
||||
|
||||
|
||||
if (!isEncrypted) {
|
||||
// Only show account setting state and room state setting state in non-e2ee rooms where they apply
|
||||
const accountEnabled = SettingsStore.getValueAt(SettingLevel.ACCOUNT, "urlPreviewsEnabled");
|
||||
if (accountEnabled) {
|
||||
previewsForAccount = (
|
||||
_t("You have <a>enabled</a> URL previews by default.", {}, { 'a': (sub)=><a href="#/settings">{ sub }</a> })
|
||||
_t("You have <a>enabled</a> URL previews by default.", {}, {
|
||||
'a': (sub)=><a href="#/settings">{ sub }</a>,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
} else if (accountEnabled) {
|
||||
previewsForAccount = (
|
||||
_t("You have <a>disabled</a> URL previews by default.", {}, { 'a': (sub)=><a href="#/settings">{ sub }</a> })
|
||||
_t("You have <a>disabled</a> URL previews by default.", {}, {
|
||||
'a': (sub)=><a href="#/settings">{ sub }</a>,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
let previewsForRoom = null;
|
||||
if (SettingsStore.canSetValue("urlPreviewsEnabled", roomId, "room")) {
|
||||
previewsForRoom = (
|
||||
<label>
|
||||
|
@ -70,6 +86,12 @@ module.exports = React.createClass({
|
|||
}
|
||||
previewsForRoom = (<label>{ _t(str) }</label>);
|
||||
}
|
||||
} else {
|
||||
previewsForAccount = (
|
||||
_t("URL Previews default to off in End-to-End Encrypted rooms to protect your privacy. " +
|
||||
"They are requested through your homeserver which could infer links which are otherwise encrypted")
|
||||
);
|
||||
}
|
||||
|
||||
const previewsForRoomAccount = (
|
||||
<SettingsFlag name="urlPreviewsEnabled"
|
||||
|
|
Loading…
Reference in a new issue