add user_is_online field in Users, pass userid when subscribing for Users, only subscribe after the user has joined (must verify)

This commit is contained in:
Anton Georgiev 2014-10-29 20:40:39 +00:00
parent 22ac2f7bb4
commit e827efbbbc
3 changed files with 21 additions and 4 deletions

View File

@ -19,7 +19,7 @@
if meetingId? and userId? and authToken?
Meteor.call("validateAuthToken", meetingId, userId, authToken)
Meteor.call('sendMeetingInfoToClient', meetingId, userId)
#Meteor.call('sendMeetingInfoToClient', meetingId, userId)
self.redirect('/')
else
console.log "unable to extract from the URL some of {meetingId, userId, authToken}"
@ -29,8 +29,11 @@
path: "/"
onBeforeAction: ->
self = @
console.log "meetingId:" + getInSession 'meetingId'
console.log "userId:" + getInSession 'userId'
Meteor.call('sendMeetingInfoToClient', getInSession('meetingId'),getInSession('userId'))
# Have to check on the server whether the credentials the user has are valid on db, without being able to spam requests for credentials
Meteor.subscribe 'users', getInSession('meetingId'), -> # callback for after users have been loaded on client
Meteor.subscribe 'users', getInSession('meetingId'), getInSession("userId"), -> # callback for after users have been loaded on client
Meteor.subscribe 'chat', getInSession('meetingId'), getInSession("userId"), ->
Meteor.subscribe 'shapes', getInSession('meetingId'), ->
Meteor.subscribe 'slides', getInSession('meetingId'), ->

View File

@ -186,6 +186,7 @@ Meteor.methods
permissions: user.permissions
locked: user.locked
time_of_joining: user.timeOfJoining
user_is_online: false # TODO consider other default value
voiceUser:
web_userid: user.voiceUser.web_userid
callernum: user.voiceUser.callernum

View File

@ -1,7 +1,20 @@
# Publish only the users that are in the particular meetingId
# On the client side we pass the meetingId parameter
Meteor.publish 'users', (meetingId) ->
Meteor.Users.find({meetingId: meetingId}, {fields: { 'userId': 0, 'user.userid': 0, 'user.extern_userid': 0, 'user.voiceUser.userid': 0, 'user.voiceUser.web_userid': 0 }})
Meteor.publish 'users', (meetingId, userid) ->
console.log "publishing users for #{meetingId}, #{userid}"
if Meteor.Users.find({meetingId: meetingId, userId: userid})?
console.log "found it from the first time"
return Meteor.Users.find({meetingId: meetingId}, {fields: { 'userId': 0, 'user.userid': 0, 'user.extern_userid': 0, 'user.voiceUser.userid': 0, 'user.voiceUser.web_userid': 0 }})
else
Meteor.Users.find({meetingId: meetingId}).observe({
added: ->
console.log "finally user with id:#{userid} joined"
return Meteor.Users.find({meetingId: meetingId}, {fields: { 'userId': 0, 'user.userid': 0, 'user.extern_userid': 0, 'user.voiceUser.userid': 0, 'user.voiceUser.web_userid': 0 }})
})
Meteor.publish 'chat', (meetingId, userid) ->
me = Meteor.Users.findOne({meetingId: meetingId, userId: userid})