/
runAction.js
41 lines (36 loc) · 975 Bytes
/
runAction.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var task = {};
/////////////////////////////////////////////////////////////////////
// metadata
task.name = "runAction";
task.description = "I will run an action and return the connection object";
task.scope = "any";
task.frequency = 0;
/////////////////////////////////////////////////////////////////////
// functional
task.run = function(api, params, next){
if(params == null){params = {};}
var connection = {
type: "task",
params: params,
error: false,
remoteIP: "task",
action: params.action,
response: {}
};
api.processAction(api, connection, null, function(connection, cont){
if(connection.error){
api.log("task error: "+connection.error, "red");
}else{
if(api.configData.log.logRequests){
api.logJSON({
label: "action @ task",
params: JSON.stringify(params),
}, "grey");
}
}
next(true, connection);
})
};
/////////////////////////////////////////////////////////////////////
// exports
exports.task = task;