Commit d24dd439 by zCaesar

edit on_delivery to on_deliver

parent 9547c678
...@@ -31,6 +31,8 @@ module.exports = function (options = {}) { ...@@ -31,6 +31,8 @@ module.exports = function (options = {}) {
var cachekey = 'sub:' + req.body.client_id + ':' + req.body.username + ':' + topic; var cachekey = 'sub:' + req.body.client_id + ':' + req.body.username + ':' + topic;
var authstatus = cache.get(cachekey); var authstatus = cache.get(cachekey);
// checkRole
var role = require('./checkClientRole')
// Set Response // Set Response
var getGroupID = require('./utils/getGroupID').getGroupID var getGroupID = require('./utils/getGroupID').getGroupID
getGroupID(req.body.username, req.body.client_id, (_id) => { // get groupID getGroupID(req.body.username, req.body.client_id, (_id) => { // get groupID
...@@ -43,7 +45,7 @@ module.exports = function (options = {}) { ...@@ -43,7 +45,7 @@ module.exports = function (options = {}) {
var response = { var response = {
'result': 'ok', 'result': 'ok',
'topics': _topic 'topics': _topic
} }
if (typeof (authstatus) == 'undefined') { if (typeof (authstatus) == 'undefined') {
// cache missed // cache missed
......
...@@ -11,7 +11,7 @@ var auth_on_register = require('./auth_on_register')({ debug: auth_on_register_d ...@@ -11,7 +11,7 @@ var auth_on_register = require('./auth_on_register')({ debug: auth_on_register_d
var auth_on_publish = require('./auth_on_publish')({ debug: auth_on_publish_debug }); var auth_on_publish = require('./auth_on_publish')({ debug: auth_on_publish_debug });
var auth_on_subscribe = require('./auth_on_subscribe')({ debug: auth_on_subscribe_debug }); var auth_on_subscribe = require('./auth_on_subscribe')({ debug: auth_on_subscribe_debug });
var on_publish = require('./on_publish')({ debug: on_publish_debug }); var on_publish = require('./on_publish')({ debug: on_publish_debug });
var on_delivery = require('./on_delivery').on_delivery var on_deliver = require('./on_deliver').on_deliver
var signRole = require('./checkClientRole').signRole var signRole = require('./checkClientRole').signRole
const server = restify.createServer({ const server = restify.createServer({
...@@ -35,7 +35,7 @@ server.get('/about', function (req, res, next) { ...@@ -35,7 +35,7 @@ server.get('/about', function (req, res, next) {
server.post('/authreg', auth_on_register); server.post('/authreg', auth_on_register);
server.post('/authpub', auth_on_publish); server.post('/authpub', auth_on_publish);
server.post('/authsub', auth_on_subscribe); server.post('/authsub', auth_on_subscribe);
server.post('/ondelivery', on_delivery) server.post('/ondeliver', on_deliver)
server.post('/onpub', on_publish) server.post('/onpub', on_publish)
server.post('/signRole', signRole) server.post('/signRole', signRole)
......
function on_delivery(req, res, next) { function on_deliver(req, res, next) {
var topics = beDesireTopic(req.body.topic) var topics = beDesireTopic(req.body.topic)
var response = { var response = {
'result': 'ok', 'result': 'ok',
...@@ -8,7 +8,7 @@ function on_delivery(req, res, next) { ...@@ -8,7 +8,7 @@ function on_delivery(req, res, next) {
} }
res.send(response) res.send(response)
} }
module.exports.on_delivery = on_delivery module.exports.on_deliver = on_deliver
function hasGroup(topics) { function hasGroup(topics) {
if (topics.indexOf('!') > -1) { if (topics.indexOf('!') > -1) {
......
function getTopic(topic, id) { function getTopic(topic, id) {
if (!checkWildCard(topic)) { var _topic = classifiedTopic(topic) + '/!' + id + topic.split(classifiedTopic(topic))[1]
var _topic = classifiedTopic(topic) + '/!' + id + topic.split(classifiedTopic(topic))[1] return _topic
return _topic
}
else return topic
} }
module.exports.getTopic = getTopic module.exports.getTopic = getTopic
...@@ -19,9 +16,4 @@ function classifiedTopic(topic) { ...@@ -19,9 +16,4 @@ function classifiedTopic(topic) {
} else if (topic.indexOf('@client') !== -1) { } else if (topic.indexOf('@client') !== -1) {
return '@client' return '@client'
} }
}
function checkWildCard(topic) {
if (topic.indexOf('#') > -1) return true
else return false
} }
\ No newline at end of file
...@@ -814,8 +814,8 @@ vmq_webhooks.webhook3.endpoint = http://localhost:40000/authpub ...@@ -814,8 +814,8 @@ vmq_webhooks.webhook3.endpoint = http://localhost:40000/authpub
vmq_webhooks.webhook4.hook = on_publish vmq_webhooks.webhook4.hook = on_publish
vmq_webhooks.webhook4.endpoint = http://localhost:41000/onpub vmq_webhooks.webhook4.endpoint = http://localhost:41000/onpub
vmq_webhooks.webhook5.hook = on_delivery vmq_webhooks.webhook5.hook = on_deliver
vmq_webhooks.webhook5.endpoint = http://localhost:40000/ondelivery vmq_webhooks.webhook5.endpoint = http://localhost:40000/ondeliver
## Specify the address and port of the bridge to connect to. Several ## Specify the address and port of the bridge to connect to. Several
## bridges can configured by using different bridge names (e.g. br0). If the ## bridges can configured by using different bridge names (e.g. br0). If the
......
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