From 1c6312d99950aa0a34a355e378fc43929dd66fd4 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Wed, 14 Aug 2019 14:02:25 +0100 Subject: [PATCH] Store ICE fallback permission in device setting This stores the ICE server fallback permission in a device setting so it is remembered across sessions. Part of https://github.com/matrix-org/matrix-react-sdk/pull/3309 --- src/MatrixClientPeg.js | 1 + src/components/structures/MatrixChat.js | 14 +++++++------- .../settings/tabs/user/VoiceUserSettingsTab.js | 15 ++++++++++++++- src/i18n/strings/en_EN.json | 3 ++- src/settings/Settings.js | 6 ++++++ 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index d2760bc82c..813f0ed87e 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -216,6 +216,7 @@ class MatrixClientPeg { deviceId: creds.deviceId, timelineSupport: true, forceTURN: !SettingsStore.getValue('webRtcAllowPeerToPeer', false), + fallbackICEServerAllowed: !!SettingsStore.getValue('fallbackICEServerAllowed'), verificationMethods: [verificationMethods.SAS], unstableClientRelationAggregation: true, }; diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index ff30bb1605..f935303c0a 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -1386,18 +1386,18 @@ export default React.createClass({ ) }

{ _t( "Riot can use a fallback server turn.matrix.org " + - "for the current session if you urgently need to make a call. " + - "Your IP address would be shared with this fallback server " + - "only if you agree and later place or receive a call.", + "if you urgently need to make a call. Your IP address would be " + + "shared with this fallback server only if you agree and later " + + "place or receive a call. You can change this permission later " + + "in the Voice & Video section of Settings.", null, { code }, )}

, button: _t('Allow Fallback'), cancelButton: _t('Dismiss'), - onFinished: (confirmed) => { - if (confirmed) { - cli.setFallbackICEServerAllowed(true); - } + onFinished: (allow) => { + SettingsStore.setValue("fallbackICEServerAllowed", null, SettingLevel.DEVICE, allow); + cli.setFallbackICEServerAllowed(allow); }, }, null, true); }); diff --git a/src/components/views/settings/tabs/user/VoiceUserSettingsTab.js b/src/components/views/settings/tabs/user/VoiceUserSettingsTab.js index eb85fe4e44..18ea5a82be 100644 --- a/src/components/views/settings/tabs/user/VoiceUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/VoiceUserSettingsTab.js @@ -115,6 +115,10 @@ export default class VoiceUserSettingsTab extends React.Component { MatrixClientPeg.get().setForceTURN(!p2p); }; + _changeFallbackICEServerAllowed = (allow) => { + MatrixClientPeg.get().setFallbackICEServerAllowed(allow); + }; + _renderDeviceOptions(devices, category) { return devices.map((d) => { return (); @@ -201,7 +205,16 @@ export default class VoiceUserSettingsTab extends React.Component { {microphoneDropdown} {webcamDropdown} - + + ); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index ecfdc5642a..c74b19a223 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -355,6 +355,7 @@ "Show recently visited rooms above the room list": "Show recently visited rooms above the room list", "Show hidden events in timeline": "Show hidden events in timeline", "Low bandwidth mode": "Low bandwidth mode", + "Allow fallback call assist server turn.matrix.org": "Allow fallback call assist server turn.matrix.org", "Collecting app version information": "Collecting app version information", "Collecting logs": "Collecting logs", "Uploading report": "Uploading report", @@ -1509,7 +1510,7 @@ "This room is used for important messages from the Homeserver, so you cannot leave it.": "This room is used for important messages from the Homeserver, so you cannot leave it.", "Homeserver not configured to support calls": "Homeserver not configured to support calls", "Your homeserver %(homeserverDomain)s is currently not configured to assist with calls by offering a TURN server, which means it is likely that voice and video calls will fail. Please notify your homeserver administrator so that they can address this.": "Your homeserver %(homeserverDomain)s is currently not configured to assist with calls by offering a TURN server, which means it is likely that voice and video calls will fail. Please notify your homeserver administrator so that they can address this.", - "Riot can use a fallback server turn.matrix.org for the current session if you urgently need to make a call. Your IP address would be shared with this fallback server only if you agree and later place or receive a call.": "Riot can use a fallback server turn.matrix.org for the current session if you urgently need to make a call. Your IP address would be shared with this fallback server only if you agree and later place or receive a call.", + "Riot can use a fallback server turn.matrix.org if you urgently need to make a call. Your IP address would be shared with this fallback server only if you agree and later place or receive a call. You can change this permission later in the Voice & Video section of Settings.": "Riot can use a fallback server turn.matrix.org if you urgently need to make a call. Your IP address would be shared with this fallback server only if you agree and later place or receive a call. You can change this permission later in the Voice & Video section of Settings.", "Allow Fallback": "Allow Fallback", "Signed Out": "Signed Out", "For security, this session has been signed out. Please sign in again.": "For security, this session has been signed out. Please sign in again.", diff --git a/src/settings/Settings.js b/src/settings/Settings.js index 55085963d1..77e1c2cb25 100644 --- a/src/settings/Settings.js +++ b/src/settings/Settings.js @@ -372,4 +372,10 @@ export const SETTINGS = { default: false, controller: new LowBandwidthController(), }, + "fallbackICEServerAllowed": { + supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS, + displayName: _td("Allow fallback call assist server turn.matrix.org"), + // This is a tri-state value, where `null` means "prompt the user". + default: null, + }, };