Add private live notifications
parent
1d38a0270a
commit
b033906e2b
|
@ -32,7 +32,11 @@ class Client
|
|||
else if msg.cmd == 'auth' and msg.data
|
||||
@.authUser(msg.data)
|
||||
else if msg.cmd == 'subscribe' and msg.routing_key
|
||||
@.addSubscription(msg.routing_key)
|
||||
if msg.routing_key.indexOf("live_notifications") == 0
|
||||
userId = signing.getUserId(@.auth.token)
|
||||
@.addSubscription("live_notifications.#{userId}")
|
||||
else
|
||||
@.addSubscription(msg.routing_key)
|
||||
else if msg.cmd == 'unsubscribe' and msg.routing_key
|
||||
@.removeSubscription(msg.routing_key)
|
||||
|
||||
|
|
|
@ -12,6 +12,11 @@ rsplit = (token, sep, maxsplit) ->
|
|||
|
||||
return split
|
||||
|
||||
exports.getUserId = (token) ->
|
||||
value = token.split(':')[0]
|
||||
value = JSON.parse(base64url.decode(value))
|
||||
return value.user_authentication_id
|
||||
|
||||
exports.verify = (token) ->
|
||||
[value, sig] = rsplit(token, ':', 1)
|
||||
|
||||
|
|
Loading…
Reference in New Issue