diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js
index 4beafb099c..8f03199a62 100644
--- a/src/components/structures/RoomView.js
+++ b/src/components/structures/RoomView.js
@@ -1,6 +1,7 @@
/*
Copyright 2015, 2016 OpenMarket Ltd
Copyright 2017 Vector Creations Ltd
+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.
@@ -618,9 +619,11 @@ module.exports = React.createClass({
}
},
- _updatePreviewUrlVisibility: function(room) {
+ _updatePreviewUrlVisibility: function({roomId}) {
+ // 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("urlPreviewsEnabled", room.roomId),
+ showUrlPreview: SettingsStore.getValue(key, roomId),
});
},
@@ -645,19 +648,23 @@ module.exports = React.createClass({
},
onAccountData: function(event) {
- if (event.getType() === "org.matrix.preview_urls" && this.state.room) {
+ const type = event.getType();
+ if ((type === "org.matrix.preview_urls" || type === "im.vector.web.settings") && this.state.room) {
+ // non-e2ee url previews are stored in legacy event type `org.matrix.room.preview_urls`
this._updatePreviewUrlVisibility(this.state.room);
}
},
onRoomAccountData: function(event, room) {
if (room.roomId == this.state.roomId) {
- if (event.getType() === "org.matrix.room.color_scheme") {
+ const type = event.getType();
+ if (type === "org.matrix.room.color_scheme") {
const color_scheme = event.getContent();
// XXX: we should validate the event
console.log("Tinter.tint from onRoomAccountData");
Tinter.tint(color_scheme.primary_color, color_scheme.secondary_color);
- } else if (event.getType() === "org.matrix.room.preview_urls") {
+ } else if (type === "org.matrix.room.preview_urls" || type === "im.vector.web.settings") {
+ // non-e2ee url previews are stored in legacy event type `org.matrix.room.preview_urls`
this._updatePreviewUrlVisibility(room);
}
}
diff --git a/src/components/views/room_settings/UrlPreviewSettings.js b/src/components/views/room_settings/UrlPreviewSettings.js
index ed58d610aa..fe2a2bacf4 100644
--- a/src/components/views/room_settings/UrlPreviewSettings.js
+++ b/src/components/views/room_settings/UrlPreviewSettings.js
@@ -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,42 +45,58 @@ 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")) {
- previewsForAccount = (
- _t("You have enabled URL previews by default.", {}, { 'a': (sub)=>{ sub } })
- );
- } else {
- previewsForAccount = (
- _t("You have disabled URL previews by default.", {}, { 'a': (sub)=>{ sub } })
- );
- }
-
let previewsForRoom = null;
- if (SettingsStore.canSetValue("urlPreviewsEnabled", roomId, "room")) {
- previewsForRoom = (
-
- );
- } else {
- let str = _td("URL previews are enabled by default for participants in this room.");
- if (!SettingsStore.getValueAt(SettingLevel.ROOM, "urlPreviewsEnabled", roomId, /*explicit=*/true)) {
- str = _td("URL previews are disabled by default for participants in this room.");
+
+ 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 enabled URL previews by default.", {}, {
+ 'a': (sub)=>{ sub },
+ })
+ );
+ } else if (accountEnabled) {
+ previewsForAccount = (
+ _t("You have disabled URL previews by default.", {}, {
+ 'a': (sub)=>{ sub },
+ })
+ );
}
- previewsForRoom = ();
+
+ if (SettingsStore.canSetValue("urlPreviewsEnabled", roomId, "room")) {
+ previewsForRoom = (
+
+ );
+ } else {
+ let str = _td("URL previews are enabled by default for participants in this room.");
+ if (!SettingsStore.getValueAt(SettingLevel.ROOM, "urlPreviewsEnabled", roomId, /*explicit=*/true)) {
+ str = _td("URL previews are disabled by default for participants in this room.");
+ }
+ previewsForRoom = ();
+ }
+ } else {
+ previewsForAccount = (
+ _t("In encrypted rooms, like this one, URL previews are disabled by default to ensure that your " +
+ "homeserver (where the previews are generated) cannot gather information about links you see in " +
+ "this room.")
+ );
}
- const previewsForRoomAccount = (
-
@@ -83,8 +105,13 @@ module.exports = React.createClass({
return (
{ _t("URL Previews") }
-
-
+
+ { _t('When someone puts a URL in their message, a URL preview can be shown to give more ' +
+ 'information about that link such as the title, description, and an image from the website.') }
+
+
+ { previewsForAccount }
+
{ previewsForRoom }
diff --git a/src/i18n/strings/el.json b/src/i18n/strings/el.json
index f6264ce8b0..c4514f629b 100644
--- a/src/i18n/strings/el.json
+++ b/src/i18n/strings/el.json
@@ -810,7 +810,6 @@
"%(widgetName)s widget removed by %(senderName)s": "Το widget %(widgetName)s αφαιρέθηκε από τον/την %(senderName)s",
"%(names)s and %(count)s others are typing|other": "Ο/Η %(names)s και άλλοι/ες %(count)s πληκτρολογούν",
"%(names)s and %(count)s others are typing|one": "Ο/Η %(names)s και άλλος ένας πληκτρολογούν",
- "Message Replies": "Απαντήσεις",
"Message Pinning": "Καρφίτσωμα Μηνυμάτων",
"Hide avatar changes": "Απόκρυψη αλλαγών εικονιδίων χρηστών",
"Hide display name changes": "Απόκρυψη αλλαγών εμφανιζόμενων ονομάτων",
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index da47140c96..e4a66b9c12 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -42,6 +42,10 @@
"The file '%(fileName)s' failed to upload": "The file '%(fileName)s' failed to upload",
"The file '%(fileName)s' exceeds this home server's size limit for uploads": "The file '%(fileName)s' exceeds this home server's size limit for uploads",
"Upload Failed": "Upload Failed",
+ "Failure to create room": "Failure to create room",
+ "Server may be unavailable, overloaded, or you hit a bug.": "Server may be unavailable, overloaded, or you hit a bug.",
+ "Send anyway": "Send anyway",
+ "Send": "Send",
"Sun": "Sun",
"Mon": "Mon",
"Tue": "Tue",
@@ -81,6 +85,7 @@
"Failed to invite users to community": "Failed to invite users to community",
"Failed to invite users to %(groupId)s": "Failed to invite users to %(groupId)s",
"Failed to add the following rooms to %(groupId)s:": "Failed to add the following rooms to %(groupId)s:",
+ "Unnamed Room": "Unnamed Room",
"Riot does not have permission to send you notifications - please check your browser settings": "Riot does not have permission to send you notifications - please check your browser settings",
"Riot was not given permission to send notifications - please try again": "Riot was not given permission to send notifications - please try again",
"Unable to enable Notifications": "Unable to enable Notifications",
@@ -194,11 +199,6 @@
"%(names)s and %(count)s others are typing|other": "%(names)s and %(count)s others are typing",
"%(names)s and %(count)s others are typing|one": "%(names)s and one other is typing",
"%(names)s and %(lastPerson)s are typing": "%(names)s and %(lastPerson)s are typing",
- "Failure to create room": "Failure to create room",
- "Server may be unavailable, overloaded, or you hit a bug.": "Server may be unavailable, overloaded, or you hit a bug.",
- "Send anyway": "Send anyway",
- "Send": "Send",
- "Unnamed Room": "Unnamed Room",
"Your browser does not support the required cryptography extensions": "Your browser does not support the required cryptography extensions",
"Not a valid Riot keyfile": "Not a valid Riot keyfile",
"Authentication check failed: incorrect password?": "Authentication check failed: incorrect password?",
@@ -311,6 +311,31 @@
"Off": "Off",
"On": "On",
"Noisy": "Noisy",
+ "Invalid alias format": "Invalid alias format",
+ "'%(alias)s' is not a valid format for an alias": "'%(alias)s' is not a valid format for an alias",
+ "Invalid address format": "Invalid address format",
+ "'%(alias)s' is not a valid format for an address": "'%(alias)s' is not a valid format for an address",
+ "not specified": "not specified",
+ "not set": "not set",
+ "Remote addresses for this room:": "Remote addresses for this room:",
+ "Addresses": "Addresses",
+ "The main address for this room is": "The main address for this room is",
+ "Local addresses for this room:": "Local addresses for this room:",
+ "This room has no local addresses": "This room has no local addresses",
+ "New address (e.g. #foo:%(localDomain)s)": "New address (e.g. #foo:%(localDomain)s)",
+ "Invalid community ID": "Invalid community ID",
+ "'%(groupId)s' is not a valid community ID": "'%(groupId)s' is not a valid community ID",
+ "Flair": "Flair",
+ "Showing flair for these communities:": "Showing flair for these communities:",
+ "This room is not showing flair for any communities": "This room is not showing flair for any communities",
+ "New community ID (e.g. +foo:%(localDomain)s)": "New community ID (e.g. +foo:%(localDomain)s)",
+ "You have enabled URL previews by default.": "You have enabled URL previews by default.",
+ "You have disabled URL previews by default.": "You have disabled URL previews by default.",
+ "URL previews are enabled by default for participants in this room.": "URL previews are enabled by default for participants in this room.",
+ "URL previews are disabled by default for participants in this room.": "URL previews are disabled by default for participants in this room.",
+ "In encrypted rooms, like this one, URL previews are disabled by default to ensure that your homeserver (where the previews are generated) cannot gather information about links you see in this room.": "In encrypted rooms, like this one, URL previews are disabled by default to ensure that your homeserver (where the previews are generated) cannot gather information about links you see in this room.",
+ "URL Previews": "URL Previews",
+ "When someone puts a URL in their message, a URL preview can be shown to give more information about that link such as the title, description, and an image from the website.": "When someone puts a URL in their message, a URL preview can be shown to give more information about that link such as the title, description, and an image from the website.",
"Cannot add any more widgets": "Cannot add any more widgets",
"The maximum permitted number of widgets have already been added to this room.": "The maximum permitted number of widgets have already been added to this room.",
"Add a widget": "Add a widget",
@@ -410,11 +435,11 @@
"numbullet": "numbullet",
"Markdown is disabled": "Markdown is disabled",
"Markdown is enabled": "Markdown is enabled",
- "Unpin Message": "Unpin Message",
- "Jump to message": "Jump to message",
"No pinned messages.": "No pinned messages.",
"Loading...": "Loading...",
"Pinned Messages": "Pinned Messages",
+ "Unpin Message": "Unpin Message",
+ "Jump to message": "Jump to message",
"%(duration)ss": "%(duration)ss",
"%(duration)sm": "%(duration)sm",
"%(duration)sh": "%(duration)sh",
@@ -547,29 +572,6 @@
"Scroll to unread messages": "Scroll to unread messages",
"Jump to first unread message.": "Jump to first unread message.",
"Close": "Close",
- "Invalid alias format": "Invalid alias format",
- "'%(alias)s' is not a valid format for an alias": "'%(alias)s' is not a valid format for an alias",
- "Invalid address format": "Invalid address format",
- "'%(alias)s' is not a valid format for an address": "'%(alias)s' is not a valid format for an address",
- "not specified": "not specified",
- "not set": "not set",
- "Remote addresses for this room:": "Remote addresses for this room:",
- "Addresses": "Addresses",
- "The main address for this room is": "The main address for this room is",
- "Local addresses for this room:": "Local addresses for this room:",
- "This room has no local addresses": "This room has no local addresses",
- "New address (e.g. #foo:%(localDomain)s)": "New address (e.g. #foo:%(localDomain)s)",
- "Invalid community ID": "Invalid community ID",
- "'%(groupId)s' is not a valid community ID": "'%(groupId)s' is not a valid community ID",
- "Flair": "Flair",
- "Showing flair for these communities:": "Showing flair for these communities:",
- "This room is not showing flair for any communities": "This room is not showing flair for any communities",
- "New community ID (e.g. +foo:%(localDomain)s)": "New community ID (e.g. +foo:%(localDomain)s)",
- "You have enabled URL previews by default.": "You have enabled URL previews by default.",
- "You have disabled URL previews by default.": "You have disabled URL previews by default.",
- "URL previews are enabled by default for participants in this room.": "URL previews are enabled by default for participants in this room.",
- "URL previews are disabled by default for participants in this room.": "URL previews are disabled by default for participants in this room.",
- "URL Previews": "URL Previews",
"Sunday": "Sunday",
"Monday": "Monday",
"Tuesday": "Tuesday",
diff --git a/src/i18n/strings/gl.json b/src/i18n/strings/gl.json
index 1080e66a26..57d8301df6 100644
--- a/src/i18n/strings/gl.json
+++ b/src/i18n/strings/gl.json
@@ -168,7 +168,6 @@
"Authentication check failed: incorrect password?": "Fallou a comprobación de autenticación: contrasinal incorrecto?",
"Failed to join room": "Non se puido unir a sala",
"Message Pinning": "Fixando mensaxe",
- "Tag Panel": "Panel de etiquetas",
"Disable Emoji suggestions while typing": "Desactivar a suxestión de Emoji mentres escribe",
"Use compact timeline layout": "Utilizar a disposición compacta da liña temporal",
"Hide removed messages": "Ocultar mensaxes eliminadas",
diff --git a/src/i18n/strings/it.json b/src/i18n/strings/it.json
index d3f93acec5..0957bc156d 100644
--- a/src/i18n/strings/it.json
+++ b/src/i18n/strings/it.json
@@ -1175,7 +1175,6 @@
"To continue using the %(homeserverDomain)s homeserver you must review and agree to our terms and conditions.": "Per continuare a usare l'homeserver %(homeserverDomain)s devi leggere e accettare i nostri termini e condizioni.",
"Review terms and conditions": "Leggi i termini e condizioni",
"Muted Users": "Utenti silenziati",
- "Message Replies": "Risposte",
"Message Pinning": "Messaggi appuntati",
"Mirror local video feed": "Feed video dai ripetitori locali",
"Replying": "Rispondere",
diff --git a/src/settings/Settings.js b/src/settings/Settings.js
index 9f35b0bfec..84178e2673 100644
--- a/src/settings/Settings.js
+++ b/src/settings/Settings.js
@@ -245,6 +245,13 @@ export const SETTINGS = {
},
default: true,
},
+ "urlPreviewsEnabled_e2ee": {
+ supportedLevels: ['room-device', 'room-account'],
+ displayName: {
+ "room-account": _td("Enable URL previews for this room (only affects you)"),
+ },
+ default: false,
+ },
"roomColor": {
supportedLevels: LEVELS_ROOM_SETTINGS_WITH_ROOM,
displayName: _td("Room Colour"),
diff --git a/src/settings/handlers/RoomAccountSettingsHandler.js b/src/settings/handlers/RoomAccountSettingsHandler.js
index 74dbf9eed0..d0dadc2de7 100644
--- a/src/settings/handlers/RoomAccountSettingsHandler.js
+++ b/src/settings/handlers/RoomAccountSettingsHandler.js
@@ -74,7 +74,7 @@ export default class RoomAccountSettingsHandler extends SettingsHandler {
return cli !== undefined && cli !== null;
}
- _getSettings(roomId, eventType = "im.vector.settings") {
+ _getSettings(roomId, eventType = "im.vector.web.settings") {
const room = MatrixClientPeg.get().getRoom(roomId);
if (!room) return null;