index : matrix-js-sdk

My fork of matrix-js-sdk

diff options
context:
space:
mode:
authorMichael Telatynski <[email protected]>2020-06-16 10:26:08 +0100
committerGitHub <[email protected]>2020-06-16 10:26:08 +0100
commitaa2d0d9a081dd8d274d8f8a8ba1f796d17faa338 (patch)
tree1e260eeb64db3295effe9e6d8e61ea4d8d71325c
parent505915528f4b0c2e0a56809675529cd8d418508f (diff)
parentbe05452c7031a1d2f2dfdaeca153808665763c83 (diff)
downloadmatrix-js-sdk-aa2d0d9a081dd8d274d8f8a8ba1f796d17faa338.tar.gz
Merge pull request #1404 from matrix-org/t3chguy/push-rules-device
Remove support for unspecced device-specific push rules
-rw-r--r--src/pushprocessor.js36
1 files changed, 9 insertions, 27 deletions
diff --git a/src/pushprocessor.js b/src/pushprocessor.js
index da7fb04a..ecbd1bef 100644
--- a/src/pushprocessor.js
+++ b/src/pushprocessor.js
@@ -84,12 +84,15 @@ export function PushProcessor(client) {
// $glob: RegExp,
};
- const matchingRuleFromKindSet = (ev, kindset, device) => {
+ const matchingRuleFromKindSet = (ev, kindset) => {
for (let ruleKindIndex = 0;
ruleKindIndex < RULEKINDS_IN_ORDER.length;
++ruleKindIndex) {
const kind = RULEKINDS_IN_ORDER[ruleKindIndex];
const ruleset = kindset[kind];
+ if (!ruleset) {
+ continue;
+ }
for (let ruleIndex = 0; ruleIndex < ruleset.length; ++ruleIndex) {
const rule = ruleset[ruleIndex];
@@ -97,7 +100,7 @@ export function PushProcessor(client) {
continue;
}
- const rawrule = templateRuleToRaw(kind, rule, device);
+ const rawrule = templateRuleToRaw(kind, rule);
if (!rawrule) {
continue;
}
@@ -111,7 +114,7 @@ export function PushProcessor(client) {
return null;
};
- const templateRuleToRaw = function(kind, tprule, device) {
+ const templateRuleToRaw = function(kind, tprule) {
const rawrule = {
'rule_id': tprule.rule_id,
'actions': tprule.actions,
@@ -153,19 +156,12 @@ export function PushProcessor(client) {
});
break;
}
- if (device) {
- rawrule.conditions.push({
- 'kind': 'device',
- 'profile_tag': device,
- });
- }
return rawrule;
};
const eventFulfillsCondition = function(cond, ev) {
const condition_functions = {
"event_match": eventFulfillsEventMatchCondition,
- "device": eventFulfillsDeviceCondition,
"contains_display_name": eventFulfillsDisplayNameCondition,
"room_member_count": eventFulfillsRoomMemberCountCondition,
"sender_notification_permission": eventFulfillsSenderNotifPermCondition,
@@ -257,10 +253,6 @@ export function PushProcessor(client) {
return content.body.search(pat) > -1;
};
- const eventFulfillsDeviceCondition = function(cond, ev) {
- return false; // XXX: Allow a profile tag to be set for the web client instance
- };
-
const eventFulfillsEventMatchCondition = function(cond, ev) {
if (!cond.key) {
return false;
@@ -325,23 +317,13 @@ export function PushProcessor(client) {
};
const matchingRuleForEventWithRulesets = function(ev, rulesets) {
- if (!rulesets || !rulesets.device) {
+ if (!rulesets) {
return null;
}
- if (ev.getSender() == client.credentials.userId) {
+ if (ev.getSender() === client.credentials.userId) {
return null;
}
- const allDevNames = Object.keys(rulesets.device);
- for (let i = 0; i < allDevNames.length; ++i) {
- const devname = allDevNames[i];
- const devrules = rulesets.device[devname];
-
- const matchingRule = matchingRuleFromKindSet(devrules, devname);
- if (matchingRule) {
- return matchingRule;
- }
- }
return matchingRuleFromKindSet(ev, rulesets.global);
};
@@ -392,7 +374,7 @@ export function PushProcessor(client) {
* @return {object} The push rule, or null if no such rule was found
*/
this.getPushRuleById = function(ruleId) {
- for (const scope of ['device', 'global']) {
+ for (const scope of ['global']) {
if (client.pushRules[scope] === undefined) continue;
for (const kind of RULEKINDS_IN_ORDER) {