From 5446539929897ae8dc89d79222b942a77afe52cb Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Mon, 6 Apr 2015 20:00:44 +0000 Subject: [PATCH] The upsert check was incorrect, checking for exact structure. Split into findOne + insert --- .../server/collection_methods/users.coffee | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/bigbluebutton-html5/app/server/collection_methods/users.coffee b/bigbluebutton-html5/app/server/collection_methods/users.coffee index 8449ddac89..3b3980a09d 100755 --- a/bigbluebutton-html5/app/server/collection_methods/users.coffee +++ b/bigbluebutton-html5/app/server/collection_methods/users.coffee @@ -115,7 +115,7 @@ Meteor.methods @markUserOffline = (meetingId, userId) -> # mark the user as offline. remove from the collection on meeting_end #TODO Meteor.log.info "marking user [#{userId}] as offline in meeting[#{meetingId}]" - Meteor.Users.update({meetingId: meetingId, userId: userId}, {$set:{user:{connection_status:'offline'}}}) + Meteor.Users.update({'meetingId': meetingId, 'userId': userId}, {$set:{'user.connection_status':'offline'}}) # Corresponds to a valid action on the HTML clientside @@ -191,13 +191,14 @@ Meteor.methods webcam_stream: user.webcam_stream }}) - welcomeMessage = Meteor.config.defaultWelcomeMessage - .replace /%%CONFNAME%%/, Meteor.Meetings.findOne({meetingId: meetingId})?.meetingName - welcomeMessage = welcomeMessage + Meteor.config.defaultWelcomeMessageFooter + # only add the welcome message if it's not there already + unless Meteor.Chat.findOne({"message.chat_type":'SYSTEM_MESSAGE', "message.to_userid": userId})? + welcomeMessage = Meteor.config.defaultWelcomeMessage + .replace /%%CONFNAME%%/, Meteor.Meetings.findOne({meetingId: meetingId})?.meetingName + welcomeMessage = welcomeMessage + Meteor.config.defaultWelcomeMessageFooter - # store the welcome message in chat for easy display on the client side - chatId = Meteor.Chat.upsert({message:{chat_type:'SYSTEM_MESSAGE', to_userid: userId}, meetingId: meetingId}, - {$set:{ + # store the welcome message in chat for easy display on the client side + Meteor.Chat.insert( meetingId: meetingId message: chat_type: "SYSTEM_MESSAGE" @@ -207,8 +208,8 @@ Meteor.methods from_userid: "SYSTEM_MESSAGE" from_username: "" from_time: user.timeOfJoining?.toString() - }}) - 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 # scenario: there are meetings running at the time when the meteor