diff --git a/lib/pushprocessor.js b/lib/pushprocessor.js index 432f39066..06bd20fe9 100644 --- a/lib/pushprocessor.js +++ b/lib/pushprocessor.js @@ -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; diff --git a/lib/sync.js b/lib/sync.js index fcc992746..91bb0cc51 100644 --- a/lib/sync.js +++ b/lib/sync.js @@ -613,6 +613,9 @@ SyncApi.prototype._processSyncResponse = function(syncToken, data) { client.store.storeAccountDataEvents(events); events.forEach( function(accountDataEvent) { + if (accountDataEvent.getType() == 'm.push_rules') { + client.pushRules = accountDataEvent.getContent(); + } client.emit("accountData", accountDataEvent); return accountDataEvent; }