Skip to content

Commit

Permalink
Moves fetching current user to a helper
Browse files Browse the repository at this point in the history
Signed-off-by: Akash Manohar J <akash@akash.im>
  • Loading branch information
HashNuke committed Mar 12, 2012
1 parent 8b48262 commit 4472358
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/assets/javascripts/backbone/broadcasters/faye.js.coffee
Expand Up @@ -6,15 +6,15 @@ class Kandan.Broadcasters.FayeBroadcaster
auth_extension = {
outgoing: (message, callback)->
if message.channel == "/meta/subscribe"
# TODO move fetching auth token to a helper
message['ext'] = {auth_token: $.data(document, 'current_user').auth_token}
message['ext'] = {
auth_token: Kandan.Helpers.Users.current_user().auth_token
}
callback(message)
}
@faye_client.addExtension(auth_extension)


subscribe: (channel)->
console.log "Subscribing to #{channel}"
@faye_client.subscribe channel, (data)=>
console.log data.user
Kandan.Helpers.Channels.add_activity(data)
console.log data.user.first_name, "says", data.content
3 changes: 3 additions & 0 deletions app/assets/javascripts/backbone/helpers/users.js.coffee
@@ -0,0 +1,3 @@
class Kandan.Helpers.Users
@current_user: ()->
$.data(document, 'current_user')

0 comments on commit 4472358

Please sign in to comment.