Commit 14c11a3b by zCaesar

add utils are getGroupID and getTopic

parent f644cd7a
var getRole = require('../checkClientRole').getRole
function getGroupID(token, id, cb) {
checkID(token, id, (groupId) => {
// console.log(groupId)
cb(groupId)
})
}
module.exports.getGroupID = getGroupID
function checkID(token, id, cb) {
// console.log(token)
getRole(token, (role) => {
// console.log(role)
if (role.hasOwnProperty('groupId')) {
cb(role.info.groupId)
}
else {
doDB(id, (groupId) => {
// console.log(groupId)
cb(groupId)
})
}
})
}
function doDB(id, cb) {
var groupId = 'test'
cb(groupId)
}
\ No newline at end of file
function getTopic(topic, id) {
var _topic = classifiedTopic(topic) + '/!' + id + topic.split(classifiedTopic(topic))[1]
return _topic
}
module.exports.getTopic = getTopic
function classifiedTopic(topic) {
if (topic.indexOf('@msg') !== -1) {
return '@msg'
} else if (topic.indexOf('@shadow/updated') !== -1) {
return '@shadow/updated'
} else if (topic.indexOf('@shadow/update') !== -1) {
return '@shadow/update'
} else if (topic.indexOf('@shadow/get') !== -1) {
return '@shadow/get'
} else if (topic.indexOf('@client') !== -1) {
return '@client'
}
}
\ No newline at end of file
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