From acbc84a69c3374319d33fa6551597d36d8049aa9 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 22 Jun 2018 18:44:54 +0100 Subject: [PATCH] switch to another settings key for e2e url previews to protect on change Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/RoomView.js | 25 ++++--------------- .../views/room_settings/UrlPreviewSettings.js | 9 +++---- src/settings/Settings.js | 7 ++++++ 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index e2de91c035..af994d298f 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -620,26 +620,11 @@ module.exports = React.createClass({ }, _updatePreviewUrlVisibility: function({roomId}) { - const levels = [ - SettingLevel.ROOM_DEVICE, - SettingLevel.ROOM_ACCOUNT, - ]; - let showUrlPreview; - // in e2ee rooms only care about room-device and room-account, so that user has to explicitly enable previews - 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}); + // URL Previews in E2EE rooms can be a privacy leak so use a different setting which is per-room explicit + const key = MatrixClientPeg.get().isRoomEncrypted(roomId) ? 'urlPreviewsEnabled_e2ee' : 'urlPreviewsEnabled'; + this.setState({ + showUrlPreview: SettingsStore.getValue(key, roomId), + }); }, onRoom: function(room) { diff --git a/src/components/views/room_settings/UrlPreviewSettings.js b/src/components/views/room_settings/UrlPreviewSettings.js index 6d3c6317d9..fe2a2bacf4 100644 --- a/src/components/views/room_settings/UrlPreviewSettings.js +++ b/src/components/views/room_settings/UrlPreviewSettings.js @@ -50,7 +50,6 @@ module.exports = React.createClass({ let previewsForAccount = null; 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"); @@ -73,7 +72,7 @@ module.exports = React.createClass({