Commit 8c7a1e24 by Chavee Issariyapat

fix bug

parent b4058f37
...@@ -22,12 +22,15 @@ module.exports = function(options={}) { ...@@ -22,12 +22,15 @@ 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') { if (data.topic.substring(0,5) == '$exec') {
var a = data.topic.split('/'); var a = data.topic.split('/');
var p = data.payload.split(':'); var ptext = Buffer.from(data.payload, 'base64').toString();
// temp
var p = ptext.split(':');
switch (a[1]) { switch (a[1]) {
case 'wf' : case 'wf' :
...@@ -35,19 +38,17 @@ module.exports = function(options={}) { ...@@ -35,19 +38,17 @@ module.exports = function(options={}) {
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], "value": p[0], // temp
"tags":{"attr":p[1]} "tags":{"attr":p[1]} // temp
}]; }];
break; 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