Revert "Merge pull request #2395 from matrix-org/dbkr/merge_develop_experimental"

This reverts commit ad47144355.
This commit is contained in:
David Baker
2019-01-03 18:55:56 +00:00
committed by Travis Ralston
parent d111fe27bb
commit f928be6f59
77 changed files with 598 additions and 3532 deletions

View File

@@ -20,7 +20,6 @@ import { _td } from '../languageHandler';
const StandardActions = require('./StandardActions');
const PushRuleVectorState = require('./PushRuleVectorState');
const { decodeActions } = require('./NotificationUtils');
class VectorPushRuleDefinition {
constructor(opts) {
@@ -32,11 +31,13 @@ class VectorPushRuleDefinition {
// Translate the rule actions and its enabled value into vector state
ruleToVectorState(rule) {
let enabled = false;
let actions = null;
if (rule) {
enabled = rule.enabled;
actions = rule.actions;
}
for (const stateKey in PushRuleVectorState.states) { // eslint-disable-line guard-for-in
for (const stateKey in PushRuleVectorState.states) {
const state = PushRuleVectorState.states[stateKey];
const vectorStateToActions = this.vectorStateToActions[state];
@@ -46,21 +47,15 @@ class VectorPushRuleDefinition {
return state;
}
} else {
// The actions must match to the ones expected by vector state.
// Use `decodeActions` on both sides to canonicalize things like
// value: true vs. unspecified for highlight (which defaults to
// true, making them equivalent).
if (enabled &&
JSON.stringify(decodeActions(rule.actions)) ===
JSON.stringify(decodeActions(vectorStateToActions))) {
// The actions must match to the ones expected by vector state
if (enabled && JSON.stringify(rule.actions) === JSON.stringify(vectorStateToActions)) {
return state;
}
}
}
console.error(`Cannot translate rule actions into Vector rule state. ` +
`Rule: ${JSON.stringify(rule)}, ` +
`Expected: ${JSON.stringify(this.vectorStateToActions)}`);
console.error("Cannot translate rule actions into Vector rule state. Rule: " +
JSON.stringify(rule));
return undefined;
}
}
@@ -91,17 +86,6 @@ module.exports = {
},
}),
// Messages containing @room
".m.rule.roomnotif": new VectorPushRuleDefinition({
kind: "override",
description: _td("Messages containing @room"), // 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,
},
}),
// Messages just sent to the user in a 1:1 room
".m.rule.room_one_to_one": new VectorPushRuleDefinition({
kind: "underride",
@@ -113,17 +97,6 @@ module.exports = {
},
}),
// Encrypted messages just sent to the user in a 1:1 room
".m.rule.encrypted_room_one_to_one": new VectorPushRuleDefinition({
kind: "underride",
description: _td("Encrypted messages in one-to-one chats"), // passed through _t() translation in src/components/views/settings/Notifications.js
vectorStateToActions: {
on: StandardActions.ACTION_NOTIFY,
loud: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND,
off: StandardActions.ACTION_DONT_NOTIFY,
},
}),
// Messages just sent to a group chat room
// 1:1 room messages are catched by the .m.rule.room_one_to_one rule if any defined
// By opposition, all other room messages are from group chat rooms.
@@ -137,19 +110,6 @@ module.exports = {
},
}),
// Encrypted messages just sent to a group chat room
// Encrypted 1:1 room messages are catched by the .m.rule.encrypted_room_one_to_one rule if any defined
// By opposition, all other room messages are from group chat rooms.
".m.rule.encrypted": new VectorPushRuleDefinition({
kind: "underride",
description: _td("Encrypted messages in group chats"), // passed through _t() translation in src/components/views/settings/Notifications.js
vectorStateToActions: {
on: StandardActions.ACTION_NOTIFY,
loud: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND,
off: StandardActions.ACTION_DONT_NOTIFY,
},
}),
// Invitation for the user
".m.rule.invite_for_me": new VectorPushRuleDefinition({
kind: "underride",