From cc72d35c6b175ef030eb777cbea1a4f77ba3b881 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 16 Aug 2016 17:02:18 +0100 Subject: [PATCH] Move definition So we don't have to fudge the jsdoc to make the linter happy --- lib/pushprocessor.js | 53 +++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/lib/pushprocessor.js b/lib/pushprocessor.js index 7c6aa69da..0580286f2 100644 --- a/lib/pushprocessor.js +++ b/lib/pushprocessor.js @@ -17,28 +17,6 @@ limitations under the License. * @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. * @constructor @@ -269,7 +247,7 @@ function PushProcessor(client) { var rule = matchingRuleForEventWithRulesets(ev, rulesets); 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 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 * @type {Object} @@ -307,10 +307,3 @@ function PushProcessor(client) { /** The PushProcessor class. */ module.exports = PushProcessor; -/** - * See above - * @param {array} actionlist The actions list - * - * @return {object} See above - */ -module.exports.actionListToActionsObject = actionListToActionsObject;