You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
Move definition
So we don't have to fudge the jsdoc to make the linter happy
This commit is contained in:
@@ -17,28 +17,6 @@ limitations under the License.
|
|||||||
* @module pushprocessor
|
* @module pushprocessor
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a list of actions into a object with the actions as keys and their values
|
|
||||||
* eg. [ 'notify', { set_tweak: 'sound', value: 'default' } ]
|
|
||||||
* becomes { notify: true, tweaks: { sound: 'default' } }
|
|
||||||
* @param {array} actionlist The actions list
|
|
||||||
*
|
|
||||||
* @return {object} A object with key 'notify' (true or false) and an object of actions
|
|
||||||
*/
|
|
||||||
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
|
||||||
@@ -269,7 +247,7 @@ function PushProcessor(client) {
|
|||||||
var rule = matchingRuleForEventWithRulesets(ev, rulesets);
|
var rule = matchingRuleForEventWithRulesets(ev, rulesets);
|
||||||
if (!rule) { return {}; }
|
if (!rule) { return {}; }
|
||||||
|
|
||||||
var actionObj = actionListToActionsObject(rule.actions);
|
var actionObj = PushProcessor.actionListToActionsObject(rule.actions);
|
||||||
|
|
||||||
// Some actions are implicit in some situations: we add those here
|
// Some actions are implicit in some situations: we add those here
|
||||||
if (actionObj.tweaks.highlight === undefined) {
|
if (actionObj.tweaks.highlight === undefined) {
|
||||||
@@ -293,6 +271,28 @@ function PushProcessor(client) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a list of actions into a object with the actions as keys and their values
|
||||||
|
* eg. [ 'notify', { set_tweak: 'sound', value: 'default' } ]
|
||||||
|
* becomes { notify: true, tweaks: { sound: 'default' } }
|
||||||
|
* @param {array} actionlist The actions list
|
||||||
|
*
|
||||||
|
* @return {object} A object with key 'notify' (true or false) and an object of actions
|
||||||
|
*/
|
||||||
|
PushProcessor.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;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} PushAction
|
* @typedef {Object} PushAction
|
||||||
* @type {Object}
|
* @type {Object}
|
||||||
@@ -307,10 +307,3 @@ function PushProcessor(client) {
|
|||||||
/** The PushProcessor class. */
|
/** The PushProcessor class. */
|
||||||
module.exports = PushProcessor;
|
module.exports = PushProcessor;
|
||||||
|
|
||||||
/**
|
|
||||||
* See above
|
|
||||||
* @param {array} actionlist The actions list
|
|
||||||
*
|
|
||||||
* @return {object} See above
|
|
||||||
*/
|
|
||||||
module.exports.actionListToActionsObject = actionListToActionsObject;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user