use UPSERT for meetings and users
This commit is contained in:
parent
67b4ab69fb
commit
a4dd3d63e4
@ -3,27 +3,25 @@
|
|||||||
# --------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------------
|
||||||
@addMeetingToCollection = (meetingId, name, intendedForRecording, voiceConf, duration) ->
|
@addMeetingToCollection = (meetingId, name, intendedForRecording, voiceConf, duration) ->
|
||||||
#check if the meeting is already in the collection
|
#check if the meeting is already in the collection
|
||||||
unless Meteor.Meetings.findOne({meetingId: meetingId})?
|
|
||||||
entry =
|
|
||||||
meetingId: meetingId
|
|
||||||
meetingName: name
|
|
||||||
intendedForRecording: intendedForRecording
|
|
||||||
currentlyBeingRecorded: false # defaut value
|
|
||||||
voiceConf: voiceConf
|
|
||||||
duration: duration
|
|
||||||
roomLockSettings:
|
|
||||||
# by default the lock settings will be disabled on meeting create
|
|
||||||
disablePrivateChat: false
|
|
||||||
disableCam: false
|
|
||||||
disableMic: false
|
|
||||||
lockOnJoin: Meteor.config.lockOnJoin
|
|
||||||
lockedLayout: false
|
|
||||||
disablePublicChat: false
|
|
||||||
lockOnJoinConfigurable: false # TODO
|
|
||||||
|
|
||||||
id = Meteor.Meetings.insert(entry)
|
obj = Meteor.Meetings.upsert({meetingId:meetingId}, {$set: {
|
||||||
Meteor.log.info "added meeting _id=[#{id}]:meetingId=[#{meetingId}]:name=[#{name}]:duration=[#{duration}]:voiceConf=[#{voiceConf}]
|
meetingName:name
|
||||||
roomLockSettings:[#{JSON.stringify entry.roomLockSettings}]."
|
intendedForRecording: intendedForRecording
|
||||||
|
currentlyBeingRecorded: false # defaut value
|
||||||
|
voiceConf: voiceConf
|
||||||
|
duration: duration
|
||||||
|
roomLockSettings:
|
||||||
|
# by default the lock settings will be disabled on meeting create
|
||||||
|
disablePrivateChat: false
|
||||||
|
disableCam: false
|
||||||
|
disableMic: false
|
||||||
|
lockOnJoin: Meteor.config.lockOnJoin
|
||||||
|
lockedLayout: false
|
||||||
|
disablePublicChat: false
|
||||||
|
lockOnJoinConfigurable: false # TODO
|
||||||
|
}}, (err, numChanged) ->
|
||||||
|
Meteor.log.error "finished finding for MEETING #{meetingId} inserted=#{numChanged.insertedId?}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@clearMeetingsCollection = (meetingId) ->
|
@clearMeetingsCollection = (meetingId) ->
|
||||||
|
@ -157,7 +157,6 @@ Meteor.methods
|
|||||||
|
|
||||||
# end listenOnly audio for the departing user
|
# end listenOnly audio for the departing user
|
||||||
if userObject.user.listenOnly
|
if userObject.user.listenOnly
|
||||||
# Meteor.log.info("~~~~~~~YES, was in listenOnly")
|
|
||||||
listenOnlyMessage =
|
listenOnlyMessage =
|
||||||
payload:
|
payload:
|
||||||
userid: userId
|
userid: userId
|
||||||
@ -209,7 +208,7 @@ Meteor.methods
|
|||||||
# the collection already contains an entry for this user because
|
# the collection already contains an entry for this user because
|
||||||
# we added a dummy user on register_user_message (to save authToken)
|
# we added a dummy user on register_user_message (to save authToken)
|
||||||
if u? and u.authToken?
|
if u? and u.authToken?
|
||||||
Meteor.log.info "UPDATING USER #{user.userid}, authToken=#{u.authToken}, locked=#{user.locked}, username=#{user.name}"
|
Meteor.log.info "(case1) UPDATING USER #{user.userid}, authToken=#{u.authToken}, locked=#{user.locked}, username=#{user.name}"
|
||||||
Meteor.Users.update({userId:user.userid, meetingId: meetingId}, {$set:{
|
Meteor.Users.update({userId:user.userid, meetingId: meetingId}, {$set:{
|
||||||
user:
|
user:
|
||||||
userid: user.userid
|
userid: user.userid
|
||||||
@ -261,14 +260,9 @@ Meteor.methods
|
|||||||
Meteor.log.info "added a system message in chat for user #{userId}"
|
Meteor.log.info "added a system message in chat for user #{userId}"
|
||||||
|
|
||||||
else
|
else
|
||||||
# scenario: there are meetings running at the time when the meteor
|
Meteor.log.info "NOTE: got user_joined_message #{user.name} #{user.userid}"
|
||||||
# process starts. As a result we the get_users_reply message contains
|
|
||||||
# users for which we have not observed user_registered_message and
|
obj = Meteor.Users.upsert({meetingId: meetingId, userId: userId}, {
|
||||||
# hence we do not have the auth_token. There will be permission issues
|
|
||||||
# as the server collection does not have the auth_token of such users
|
|
||||||
# and cannot authorize their client side actions
|
|
||||||
Meteor.log.info "NOTE: got user_joined_message "
|
|
||||||
entry =
|
|
||||||
meetingId: meetingId
|
meetingId: meetingId
|
||||||
userId: userId
|
userId: userId
|
||||||
user:
|
user:
|
||||||
@ -297,9 +291,12 @@ Meteor.methods
|
|||||||
locked: user.voiceUser.locked
|
locked: user.voiceUser.locked
|
||||||
muted: user.voiceUser.muted
|
muted: user.voiceUser.muted
|
||||||
webcam_stream: user.webcam_stream
|
webcam_stream: user.webcam_stream
|
||||||
|
}, (err, numChanged) ->
|
||||||
|
if numChanged.insertedId?
|
||||||
|
Meteor.log.info "joining user (case2) userid=[#{userId}], id=[#{obj}]:#{user.name}.
|
||||||
|
Users.size is now #{Meteor.Users.find({meetingId: meetingId}).count()}")
|
||||||
|
|
||||||
|
|
||||||
id = Meteor.Users.insert(entry)
|
|
||||||
Meteor.log.info "joining user userid=[#{userId}], id=[#{id}]:#{user.name}. Users.size is now #{Meteor.Users.find({meetingId: meetingId}).count()}"
|
|
||||||
|
|
||||||
@createDummyUser = (meetingId, userId, authToken) ->
|
@createDummyUser = (meetingId, userId, authToken) ->
|
||||||
if Meteor.Users.findOne({userId:userId, meetingId: meetingId, authToken:authToken})?
|
if Meteor.Users.findOne({userId:userId, meetingId: meetingId, authToken:authToken})?
|
||||||
|
Loading…
Reference in New Issue
Block a user