Commit 8c7a1e24 by Chavee Issariyapat

fix bug

parent b4058f37
...@@ -22,32 +22,33 @@ module.exports = function(options={}) { ...@@ -22,32 +22,33 @@ module.exports = function(options={}) {
if (options.debug) { if (options.debug) {
console.log('on_publish-------------'); console.log('on_publish-------------');
console.log(req.body); console.log(req.body);
}
var data = req.body; var data = req.body;
if (data.topic.substring(0,5) == '$exec') {
var a = data.topic.split('/');
var ptext = Buffer.from(data.payload, 'base64').toString();
if (data.topic.substring(0,5) == '$exec') { // temp
var a = data.topic.split('/'); var p = ptext.split(':');
var p = data.payload.split(':');
switch (a[1]) { switch (a[1]) {
case 'wf' : case 'wf' :
case 'writefeed' : case 'writefeed' :
var data = [{ var data = [{
"name": a[2], "name": a[2],
"timestamp": Date.now(), "timestamp": Date.now(),
"data":data.payload, "topic": data.topic,
"payload":ptext,
"value": p[0],
"tags":{"attr":p[1]}
}];
break;
}
}
"value": p[0], // temp
"tags":{"attr":p[1]} // temp
}];
break;
}
} }
var topic = req.body.topic; var topic = req.body.topic;
var cachekey = 'pub:'+req.body.client_id +':'+ req.body.username+':'+topic; var cachekey = 'pub:'+req.body.client_id +':'+ req.body.username+':'+topic;
var authstatus = cache.get(cachekey); var authstatus = cache.get(cachekey);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment