You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-29 16:43:09 +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:
@@ -17,6 +17,20 @@ limitations under the License.
|
|||||||
* @module pushprocessor
|
* @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.
|
* Construct a Push Processor.
|
||||||
* @constructor
|
* @constructor
|
||||||
@@ -243,20 +257,6 @@ function PushProcessor(client) {
|
|||||||
return matchingRuleFromKindSet(ev, rulesets.global);
|
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 pushActionsForEventAndRulesets = function(ev, rulesets) {
|
||||||
var rule = matchingRuleForEventWithRulesets(ev, rulesets);
|
var rule = matchingRuleForEventWithRulesets(ev, rulesets);
|
||||||
if (!rule) { return {}; }
|
if (!rule) { return {}; }
|
||||||
@@ -298,3 +298,4 @@ function PushProcessor(client) {
|
|||||||
|
|
||||||
/** The PushProcessor class. */
|
/** The PushProcessor class. */
|
||||||
module.exports = PushProcessor;
|
module.exports = PushProcessor;
|
||||||
|
module.exports.actionListToActionsObject = actionListToActionsObject;
|
||||||
|
|||||||
@@ -613,6 +613,9 @@ SyncApi.prototype._processSyncResponse = function(syncToken, data) {
|
|||||||
client.store.storeAccountDataEvents(events);
|
client.store.storeAccountDataEvents(events);
|
||||||
events.forEach(
|
events.forEach(
|
||||||
function(accountDataEvent) {
|
function(accountDataEvent) {
|
||||||
|
if (accountDataEvent.getType() == 'm.push_rules') {
|
||||||
|
client.pushRules = accountDataEvent.getContent();
|
||||||
|
}
|
||||||
client.emit("accountData", accountDataEvent);
|
client.emit("accountData", accountDataEvent);
|
||||||
return accountDataEvent;
|
return accountDataEvent;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user