1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

Update our push rules when they come down stream

Also expose a useful function from pushprocessor.

Fixes https://github.com/vector-im/vector-web/issues/1495
This commit is contained in:
David Baker
2016-08-15 18:40:12 +01:00
parent 6739da5acb
commit 0ba1a1dabc
2 changed files with 18 additions and 14 deletions

View File

@@ -17,6 +17,20 @@ limitations under the License.
* @module pushprocessor
*/
function actionListToActionsObject(actionlist) {
var actionobj = { 'notify': false, 'tweaks': {} };
for (var i = 0; i < actionlist.length; ++i) {
var action = actionlist[i];
if (action === 'notify') {
actionobj.notify = true;
} else if (typeof action === 'object') {
if (action.value === undefined) { action.value = true; }
actionobj.tweaks[action.set_tweak] = action.value;
}
}
return actionobj;
};
/**
* Construct a Push Processor.
* @constructor
@@ -243,20 +257,6 @@ function PushProcessor(client) {
return matchingRuleFromKindSet(ev, rulesets.global);
};
var actionListToActionsObject = function(actionlist) {
var actionobj = { 'notify': false, 'tweaks': {} };
for (var i = 0; i < actionlist.length; ++i) {
var action = actionlist[i];
if (action === 'notify') {
actionobj.notify = true;
} else if (typeof action === 'object') {
if (action.value === undefined) { action.value = true; }
actionobj.tweaks[action.set_tweak] = action.value;
}
}
return actionobj;
};
var pushActionsForEventAndRulesets = function(ev, rulesets) {
var rule = matchingRuleForEventWithRulesets(ev, rulesets);
if (!rule) { return {}; }
@@ -298,3 +298,4 @@ function PushProcessor(client) {
/** The PushProcessor class. */
module.exports = PushProcessor;
module.exports.actionListToActionsObject = actionListToActionsObject;