2014-11-22 04:57:36 +08:00
|
|
|
# Publish only the online users that are in the particular meetingId
|
2014-06-19 23:36:51 +08:00
|
|
|
# On the client side we pass the meetingId parameter
|
2014-11-21 07:35:30 +08:00
|
|
|
Meteor.publish 'users', (meetingId, userid, authToken) ->
|
2014-11-22 04:57:36 +08:00
|
|
|
Meteor.log.info "attempt publishing users for #{meetingId}, #{userid}, #{authToken}"
|
2014-11-22 04:29:07 +08:00
|
|
|
u = Meteor.Users.findOne({'userId': userid, 'meetingId': meetingId})
|
|
|
|
if u?
|
2014-11-22 04:57:36 +08:00
|
|
|
Meteor.log.info "found it from the first time #{userid}"
|
2014-11-22 04:29:07 +08:00
|
|
|
if isAllowedTo('subscribeUsers', meetingId, userid, authToken)
|
2014-12-12 01:23:19 +08:00
|
|
|
Meteor.log.info "#{userid} was allowed to subscribe to 'users'"
|
2014-11-21 07:35:30 +08:00
|
|
|
username = u?.user?.name or "UNKNOWN"
|
2014-11-22 04:29:07 +08:00
|
|
|
|
|
|
|
# offline -> online
|
|
|
|
if u.user?.connection_status isnt 'online'
|
|
|
|
Meteor.call "validateAuthToken", meetingId, userid, authToken
|
|
|
|
|
2014-11-21 07:35:30 +08:00
|
|
|
Meteor.Users.update({'meetingId':meetingId, 'userId': userid}, {$set:{'user.connection_status': "online"}})
|
2014-11-22 04:57:36 +08:00
|
|
|
Meteor.log.info "username of the subscriber: " + username + ", connection_status becomes online"
|
2014-11-21 07:35:30 +08:00
|
|
|
|
|
|
|
@_session.socket.on("close", Meteor.bindEnvironment(=>
|
2014-11-22 04:57:36 +08:00
|
|
|
Meteor.log.info "\na user lost connection: session.id=#{@_session.id} userId = #{userid}, username=#{username}, meeting=#{meetingId}"
|
2014-11-21 07:35:30 +08:00
|
|
|
Meteor.Users.update({'meetingId':meetingId, 'userId': userid}, {$set:{'user.connection_status': "offline"}})
|
2014-11-22 04:57:36 +08:00
|
|
|
Meteor.log.info "username of the user losing connection: " + username + ", connection_status: becomes offline"
|
2014-11-22 04:29:07 +08:00
|
|
|
requestUserLeaving meetingId, userid
|
2014-11-20 04:14:19 +08:00
|
|
|
)
|
|
|
|
)
|
2014-11-21 07:35:30 +08:00
|
|
|
|
2014-11-22 04:29:07 +08:00
|
|
|
#publish the users which are not offline
|
2014-11-21 07:35:30 +08:00
|
|
|
Meteor.Users.find(
|
2014-12-11 00:23:25 +08:00
|
|
|
{meetingId: meetingId, 'user.connection_status':{$in: ["online", ""]}},
|
2014-11-22 04:29:07 +08:00
|
|
|
{fields:{'authToken': false}
|
2014-11-21 07:35:30 +08:00
|
|
|
})
|
2014-11-22 04:29:07 +08:00
|
|
|
else
|
2014-12-12 01:23:19 +08:00
|
|
|
Meteor.log.warn "was not authorized to subscribe to 'users'"
|
2015-02-06 03:58:39 +08:00
|
|
|
@error(new Meteor.Error(402, "The user was not authorized to subscribe to 'users'"))
|
2014-11-21 07:35:30 +08:00
|
|
|
|
2014-11-22 04:29:07 +08:00
|
|
|
else #subscribing before the user was added to the collection
|
|
|
|
Meteor.call "validateAuthToken", meetingId, userid, authToken
|
2014-12-12 01:23:19 +08:00
|
|
|
Meteor.log.error "there was no such user #{userid} in #{meetingId}"
|
2014-11-20 04:14:19 +08:00
|
|
|
Meteor.Users.find(
|
2014-12-11 00:23:25 +08:00
|
|
|
{meetingId: meetingId, 'user.connection_status':{$in: ["online", ""]}},
|
2014-11-21 07:35:30 +08:00
|
|
|
{fields:{'authToken': false}
|
2014-11-20 04:14:19 +08:00
|
|
|
})
|
|
|
|
|
2014-10-30 04:40:39 +08:00
|
|
|
|
2014-11-21 07:35:30 +08:00
|
|
|
Meteor.publish 'chat', (meetingId, userid, authToken) ->
|
|
|
|
if isAllowedTo('subscribeChat', meetingId, userid, authToken)
|
2015-02-06 03:58:39 +08:00
|
|
|
|
2014-11-22 04:57:36 +08:00
|
|
|
Meteor.log.info "publishing chat for #{meetingId} #{userid} #{authToken}"
|
2014-11-28 04:30:23 +08:00
|
|
|
return Meteor.Chat.find({$or: [
|
|
|
|
{'message.chat_type': 'PUBLIC_CHAT', 'meetingId': meetingId},
|
|
|
|
{'message.from_userid': userid, 'meetingId': meetingId},
|
|
|
|
{'message.to_userid': userid, 'meetingId': meetingId}
|
2015-02-06 03:58:39 +08:00
|
|
|
]})
|
|
|
|
|
|
|
|
else
|
|
|
|
@error new Meteor.Error(402, "The user was not authorized to subscribe for 'chats'")
|
|
|
|
return
|
2014-07-08 04:31:18 +08:00
|
|
|
|
2015-07-22 07:55:42 +08:00
|
|
|
Meteor.publish 'bbb_poll', (meetingId, userid, authToken) ->
|
2015-07-28 07:35:27 +08:00
|
|
|
#checking if it is allowed to see Poll Collection in general
|
2015-07-22 07:55:42 +08:00
|
|
|
if isAllowedTo('subscribePoll', meetingId, userid, authToken)
|
2015-07-28 07:35:27 +08:00
|
|
|
#checking if it is allowed to see a number of votes (presenter only)
|
2015-07-28 06:55:29 +08:00
|
|
|
if isAllowedTo('subscribeAnswers', meetingId, userid, authToken)
|
2015-07-28 07:35:27 +08:00
|
|
|
Meteor.log.info "publishing Poll for presenter: #{meetingId} #{userid} #{authToken}"
|
2015-07-28 06:55:29 +08:00
|
|
|
return Meteor.Polls.find({"poll_info.meetingId": meetingId, "poll_info.users": userid})
|
|
|
|
else
|
2015-07-28 07:35:27 +08:00
|
|
|
Meteor.log.info "publishing Poll for viewer: #{meetingId} #{userid} #{authToken}"
|
2015-07-28 06:55:29 +08:00
|
|
|
return Meteor.Polls.find({"poll_info.meetingId": meetingId, "poll_info.users": userid},
|
2015-08-02 03:27:01 +08:00
|
|
|
{fields: {"poll_info.poll.answers.num_votes": 0}})
|
2015-07-22 07:55:42 +08:00
|
|
|
else
|
|
|
|
@error new Meteor.Error(402, "The user was not authorized to subscribe for 'bbb_poll'")
|
|
|
|
return
|
|
|
|
|
2014-07-08 04:31:18 +08:00
|
|
|
Meteor.publish 'shapes', (meetingId) ->
|
|
|
|
Meteor.Shapes.find({meetingId: meetingId})
|
2014-07-08 04:58:50 +08:00
|
|
|
|
|
|
|
Meteor.publish 'slides', (meetingId) ->
|
2014-11-22 04:57:36 +08:00
|
|
|
Meteor.log.info "publishing slides for #{meetingId}"
|
2014-07-08 04:58:50 +08:00
|
|
|
Meteor.Slides.find({meetingId: meetingId})
|
|
|
|
|
2014-07-10 00:06:25 +08:00
|
|
|
Meteor.publish 'meetings', (meetingId) ->
|
2014-11-22 04:57:36 +08:00
|
|
|
Meteor.log.info "publishing meetings for #{meetingId}"
|
2014-07-10 00:06:25 +08:00
|
|
|
Meteor.Meetings.find({meetingId: meetingId})
|
2014-07-28 23:00:07 +08:00
|
|
|
|
2014-07-30 04:57:02 +08:00
|
|
|
Meteor.publish 'presentations', (meetingId) ->
|
2014-11-22 04:57:36 +08:00
|
|
|
Meteor.log.info "publishing presentations for #{meetingId}"
|
2014-07-30 04:57:02 +08:00
|
|
|
Meteor.Presentations.find({meetingId: meetingId})
|
2015-03-07 03:47:07 +08:00
|
|
|
|
|
|
|
Meteor.publish 'whiteboard-clean-status', (meetingId) ->
|
|
|
|
Meteor.log.info "whiteboard clean status #{meetingId}"
|
|
|
|
Meteor.WhiteboardCleanStatus.find({meetingId: meetingId})
|