mirror of https://github.com/vector-im/riot-web
Make blacklistUnverifiedDevices override the level order
Signed-off-by: Travis Ralston <travpc@gmail.com>pull/21833/head
parent
c7d8f3931f
commit
f7da5836e1
|
@ -1104,6 +1104,7 @@ module.exports = React.createClass({
|
||||||
SettingLevel.ROOM_DEVICE,
|
SettingLevel.ROOM_DEVICE,
|
||||||
"blacklistUnverifiedDevices",
|
"blacklistUnverifiedDevices",
|
||||||
room.roomId,
|
room.roomId,
|
||||||
|
/*explicit=*/true,
|
||||||
);
|
);
|
||||||
room.setBlacklistUnverifiedDevices(blacklistEnabled);
|
room.setBlacklistUnverifiedDevices(blacklistEnabled);
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,9 +147,12 @@ export default React.createClass({
|
||||||
return <Spinner />;
|
return <Spinner />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The global value is treated as a default for when rooms don't specify a value.
|
||||||
const client = MatrixClientPeg.get();
|
const client = MatrixClientPeg.get();
|
||||||
const blacklistUnverified = client.getGlobalBlacklistUnverifiedDevices() ||
|
let blacklistUnverified = client.getGlobalBlacklistUnverifiedDevices();
|
||||||
this.props.room.getBlacklistUnverifiedDevices();
|
if (this.props.room.getBlacklistUnverifiedDevices() !== null) {
|
||||||
|
blacklistUnverified = this.props.room.getBlacklistUnverifiedDevices();
|
||||||
|
}
|
||||||
|
|
||||||
let warning;
|
let warning;
|
||||||
if (blacklistUnverified) {
|
if (blacklistUnverified) {
|
||||||
|
|
|
@ -369,6 +369,7 @@ module.exports = React.createClass({
|
||||||
SettingLevel.ROOM_DEVICE,
|
SettingLevel.ROOM_DEVICE,
|
||||||
"blacklistUnverifiedDevices",
|
"blacklistUnverifiedDevices",
|
||||||
this.props.room.roomId,
|
this.props.room.roomId,
|
||||||
|
/*explicit=*/true,
|
||||||
);
|
);
|
||||||
this.props.room.setBlacklistUnverifiedDevices(value);
|
this.props.room.setBlacklistUnverifiedDevices(value);
|
||||||
});
|
});
|
||||||
|
@ -592,21 +593,6 @@ module.exports = React.createClass({
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
const deviceBlacklisting = SettingsStore.getValueAt(
|
|
||||||
SettingLevel.DEVICE,
|
|
||||||
"blacklistUnverifiedDevices",
|
|
||||||
this.props.room.roomId,
|
|
||||||
/*explicit=*/true
|
|
||||||
);
|
|
||||||
if (deviceBlacklisting === true) {
|
|
||||||
settings = (
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" disabled={true} checked={true} />
|
|
||||||
{ SettingsStore.getDisplayName("blacklistUnverifiedDevices", SettingLevel.ROOM_DEVICE) }
|
|
||||||
</label>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isEncrypted && roomState.mayClientSendStateEvent("m.room.encryption", cli)) {
|
if (!isEncrypted && roomState.mayClientSendStateEvent("m.room.encryption", cli)) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -70,6 +70,11 @@ export const SETTINGS = {
|
||||||
//
|
//
|
||||||
// // Optional settings controller. See SettingsController for more information.
|
// // Optional settings controller. See SettingsController for more information.
|
||||||
// controller: new MySettingController(),
|
// controller: new MySettingController(),
|
||||||
|
//
|
||||||
|
// // Optional flag to make supportedLevels be respected as the order to handle
|
||||||
|
// // settings. The first element is treated as "most preferred". The "default"
|
||||||
|
// // level is always appended to the end.
|
||||||
|
// supportedLevelsAreOrdered: false,
|
||||||
// },
|
// },
|
||||||
"feature_groups": {
|
"feature_groups": {
|
||||||
isFeature: true,
|
isFeature: true,
|
||||||
|
@ -197,7 +202,10 @@ export const SETTINGS = {
|
||||||
default: 200,
|
default: 200,
|
||||||
},
|
},
|
||||||
"blacklistUnverifiedDevices": {
|
"blacklistUnverifiedDevices": {
|
||||||
supportedLevels: ['device', 'room-device'],
|
// We specifically want to have room-device > device so that users may set a device default
|
||||||
|
// with a per-room override.
|
||||||
|
supportedLevels: ['room-device', 'device'],
|
||||||
|
supportedLevelsAreOrdered: true,
|
||||||
displayName: {
|
displayName: {
|
||||||
"default": _td('Never send encrypted messages to unverified devices from this device'),
|
"default": _td('Never send encrypted messages to unverified devices from this device'),
|
||||||
"room-device": _td('Never send encrypted messages to unverified devices in this room from this device'),
|
"room-device": _td('Never send encrypted messages to unverified devices in this room from this device'),
|
||||||
|
|
|
@ -191,14 +191,18 @@ export default class SettingsStore {
|
||||||
* @return {*} The value, or null if not found.
|
* @return {*} The value, or null if not found.
|
||||||
*/
|
*/
|
||||||
static getValueAt(level, settingName, roomId = null, explicit = false, excludeDefault = false) {
|
static getValueAt(level, settingName, roomId = null, explicit = false, excludeDefault = false) {
|
||||||
const minIndex = LEVEL_ORDER.indexOf(level);
|
|
||||||
if (minIndex === -1) throw new Error("Level " + level + " is not prioritized");
|
|
||||||
|
|
||||||
// Verify that the setting is actually a setting
|
// Verify that the setting is actually a setting
|
||||||
if (!SETTINGS[settingName]) {
|
if (!SETTINGS[settingName]) {
|
||||||
throw new Error("Setting '" + settingName + "' does not appear to be a setting.");
|
throw new Error("Setting '" + settingName + "' does not appear to be a setting.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setting = SETTINGS[settingName];
|
||||||
|
const levelOrder = (setting.supportedLevelsAreOrdered ? setting.supportedLevels : LEVEL_ORDER);
|
||||||
|
if (!levelOrder.includes("default")) levelOrder.push("default"); // always include default
|
||||||
|
|
||||||
|
const minIndex = levelOrder.indexOf(level);
|
||||||
|
if (minIndex === -1) throw new Error("Level " + level + " is not prioritized");
|
||||||
|
|
||||||
if (SettingsStore.isFeature(settingName)) {
|
if (SettingsStore.isFeature(settingName)) {
|
||||||
const configValue = SettingsStore._getFeatureState(settingName);
|
const configValue = SettingsStore._getFeatureState(settingName);
|
||||||
if (configValue === "enable") return true;
|
if (configValue === "enable") return true;
|
||||||
|
@ -215,10 +219,10 @@ export default class SettingsStore {
|
||||||
return SettingsStore._tryControllerOverride(settingName, level, roomId, value);
|
return SettingsStore._tryControllerOverride(settingName, level, roomId, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = minIndex; i < LEVEL_ORDER.length; i++) {
|
for (let i = minIndex; i < levelOrder.length; i++) {
|
||||||
const handler = handlers[LEVEL_ORDER[i]];
|
const handler = handlers[levelOrder[i]];
|
||||||
if (!handler) continue;
|
if (!handler) continue;
|
||||||
if (excludeDefault && LEVEL_ORDER[i] === "default") continue;
|
if (excludeDefault && levelOrder[i] === "default") continue;
|
||||||
|
|
||||||
const value = handler.getValue(settingName, roomId);
|
const value = handler.getValue(settingName, roomId);
|
||||||
if (value === null || value === undefined) continue;
|
if (value === null || value === undefined) continue;
|
||||||
|
|
Loading…
Reference in New Issue