From 8d8445429c97da0e7306cb318549a7576ab1fbf0 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 15 Mar 2019 14:13:15 -0600 Subject: [PATCH 1/2] Show options for .m.rule.tombstone push rules Part of vector-im/riot-web#8447 --- src/components/views/settings/Notifications.js | 2 ++ src/i18n/strings/en_EN.json | 1 + src/notifications/VectorPushRulesDefinitions.js | 11 +++++++++++ 3 files changed, 14 insertions(+) diff --git a/src/components/views/settings/Notifications.js b/src/components/views/settings/Notifications.js index b8f8279bb0..4520f5c9a1 100644 --- a/src/components/views/settings/Notifications.js +++ b/src/components/views/settings/Notifications.js @@ -507,6 +507,7 @@ module.exports = React.createClass({ //'.m.rule.member_event': 'vector', '.m.rule.call': 'vector', '.m.rule.suppress_notices': 'vector', + '.m.rule.tombstone': 'vector', // Others go to others }; @@ -562,6 +563,7 @@ module.exports = React.createClass({ //'im.vector.rule.member_event', '.m.rule.call', '.m.rule.suppress_notices', + '.m.rule.tombstone', ]; for (const i in vectorRuleIds) { const vectorRuleId = vectorRuleIds[i]; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index e23be021e8..7b26ed5cf2 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -325,6 +325,7 @@ "When I'm invited to a room": "When I'm invited to a room", "Call invitation": "Call invitation", "Messages sent by bot": "Messages sent by bot", + "When rooms are upgraded": "When rooms are upgraded", "Active call (%(roomName)s)": "Active call (%(roomName)s)", "unknown caller": "unknown caller", "Incoming voice call from %(name)s": "Incoming voice call from %(name)s", diff --git a/src/notifications/VectorPushRulesDefinitions.js b/src/notifications/VectorPushRulesDefinitions.js index 402a69e7a6..b15fb4ccd7 100644 --- a/src/notifications/VectorPushRulesDefinitions.js +++ b/src/notifications/VectorPushRulesDefinitions.js @@ -183,4 +183,15 @@ module.exports = { off: StandardActions.ACTION_DONT_NOTIFY, }, }), + + // Room upgrades (tombstones) + ".m.rule.tombstone": new VectorPushRuleDefinition({ + kind: "override", + description: _td("When rooms are upgraded"), // passed through _t() translation in src/components/views/settings/Notifications.js + vectorStateToActions: { // The actions for each vector state, or null to disable the rule. + on: StandardActions.ACTION_NOTIFY, + loud: StandardActions.ACTION_HIGHLIGHT, + off: StandardActions.ACTION_DISABLED, + }, + }), }; From e5059fdf0f82b120c50ad2c9447726b7f9885ce2 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 15 Mar 2019 14:14:00 -0600 Subject: [PATCH 2/2] Don't show Matrix-namespaced push rules which the server doesn't declare So that users can't change push rules they don't have. Similar to the behaviour in https://github.com/matrix-org/matrix-js-sdk/pull/860 --- src/components/views/settings/Notifications.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/views/settings/Notifications.js b/src/components/views/settings/Notifications.js index 4520f5c9a1..23f7cd484a 100644 --- a/src/components/views/settings/Notifications.js +++ b/src/components/views/settings/Notifications.js @@ -704,6 +704,10 @@ module.exports = React.createClass({ const rows = []; for (const i in this.state.vectorPushRules) { const rule = this.state.vectorPushRules[i]; + if (rule.rule === undefined && rule.vectorRuleId.startsWith(".m.")) { + console.warn(`Skipping render of rule ${rule.vectorRuleId} due to no underlying rule`); + continue; + } //console.log("rendering: " + rule.description + ", " + rule.vectorRuleId + ", " + rule.vectorState); rows.push(this.renderNotifRulesTableRow(rule.description, rule.vectorRuleId, rule.vectorState)); }