Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vernemq
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
stack
vernemq
Commits
260771ae
Commit
260771ae
authored
Sep 17, 2018
by
zCaesar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unsub
parent
3d0afcba
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
0 deletions
+41
-0
authhook/index.js
+2
-0
authhook/on_deliver.js
+4
-0
authhook/on_unsubscribe.js
+35
-0
No files found.
authhook/index.js
View file @
260771ae
...
@@ -13,6 +13,7 @@ var auth_on_subscribe = require('./auth_on_subscribe')({ debug: auth_on_subscrib
...
@@ -13,6 +13,7 @@ var auth_on_subscribe = require('./auth_on_subscribe')({ debug: auth_on_subscrib
var
on_publish
=
require
(
'./on_publish'
)({
debug
:
on_publish_debug
});
var
on_publish
=
require
(
'./on_publish'
)({
debug
:
on_publish_debug
});
var
on_deliver
=
require
(
'./on_deliver'
).
on_deliver
var
on_deliver
=
require
(
'./on_deliver'
).
on_deliver
var
signRole
=
require
(
'./checkClientRole'
).
signRole
var
signRole
=
require
(
'./checkClientRole'
).
signRole
var
on_unsubscribe
=
require
(
'./on_unsubscribe'
).
on_unsubscribe
const
server
=
restify
.
createServer
({
const
server
=
restify
.
createServer
({
name
:
'authhook'
,
name
:
'authhook'
,
...
@@ -39,6 +40,7 @@ server.post('/onsub', (req,res,next) => {
...
@@ -39,6 +40,7 @@ server.post('/onsub', (req,res,next) => {
console
.
log
(
req
.
body
)
console
.
log
(
req
.
body
)
res
.
send
(
''
)
res
.
send
(
''
)
})
})
server
.
post
(
'/onunsub'
,
on_unsubscribe
)
server
.
post
(
'/ondeliver'
,
on_deliver
)
server
.
post
(
'/ondeliver'
,
on_deliver
)
server
.
post
(
'/onpub'
,
on_publish
)
server
.
post
(
'/onpub'
,
on_publish
)
server
.
post
(
'/signRole'
,
signRole
)
server
.
post
(
'/signRole'
,
signRole
)
...
...
authhook/on_deliver.js
View file @
260771ae
...
@@ -19,6 +19,7 @@ function hasGroup(topics) {
...
@@ -19,6 +19,7 @@ function hasGroup(topics) {
}
}
else
return
false
else
return
false
}
}
module
.
exports
.
hasGroup
=
hasGroup
function
beDesireTopic
(
topics
)
{
function
beDesireTopic
(
topics
)
{
if
(
hasGroup
(
topics
))
{
if
(
hasGroup
(
topics
))
{
...
@@ -26,8 +27,10 @@ function beDesireTopic(topics) {
...
@@ -26,8 +27,10 @@ function beDesireTopic(topics) {
}
}
else
return
topics
else
return
topics
}
}
module
.
exports
.
beDesireTopic
=
beDesireTopic
function
joinTopic
(
topics
)
{
function
joinTopic
(
topics
)
{
var
topic
=
topics
.
split
(
'/!'
)[
1
]
var
topic
=
topics
.
split
(
'/!'
)[
1
]
return
topics
.
split
(
'/!'
)[
0
]
+
topic
.
substring
(
topic
.
indexOf
(
'/'
),
topic
.
length
)
return
topics
.
split
(
'/!'
)[
0
]
+
topic
.
substring
(
topic
.
indexOf
(
'/'
),
topic
.
length
)
}
}
module
.
exports
.
joinTopic
=
joinTopic
\ No newline at end of file
authhook/on_unsubscribe.js
0 → 100644
View file @
260771ae
function
on_unsubscribe
(
req
,
res
,
next
)
{
console
.
log
(
'------on unsubscribe-------'
)
console
.
log
(
req
.
body
)
var
topic
=
req
.
body
.
topics
[
0
];
// checkRole
var
checkRealDB
=
require
(
'./checkClientRole'
).
checkRealDB
checkRealDB
(
req
.
body
.
username
,
(
err
,
decoded
)
=>
{
if
(
err
)
{
// Set Response
var
getGroupID
=
require
(
'./utils/getGroupID'
).
getGroupID
getGroupID
(
req
.
body
.
username
,
req
.
body
.
client_id
,
(
_id
)
=>
{
// get groupID
// console.log(_id)
var
_ftopic
=
require
(
'./utils/getTopic'
).
getTopic
(
topic
,
_id
)
// get topic where concat with groupID
var
response
=
{
"result"
:
"ok"
,
"topics"
:
[
_ftopic
]
}
console
.
log
(
response
)
res
.
send
(
response
);
})
}
else
{
console
.
log
(
decoded
)
if
(
decoded
.
role
===
'realtimedb'
)
{
var
response
=
{
'result'
:
'ok'
}
console
.
log
(
response
)
res
.
send
(
response
);
}
}
})
}
module
.
exports
.
on_unsubscribe
=
on_unsubscribe
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment