inserting the chat messages we receive from bbb-apps into the Chat collection
This commit is contained in:
parent
f0a50ce174
commit
9ef70b55e9
@ -1,3 +1,21 @@
|
||||
Meteor.methods
|
||||
addToCollection: (meetingId, messageObject) ->
|
||||
|
||||
addChatToCollection: (meetingId, messageObject) ->
|
||||
console.log "before -- " + Meteor.Chat.find({meetingId: meetingId}).count()
|
||||
entry = {
|
||||
meetingId: meetingId
|
||||
message: { # or message: messageObject but this is more verbose
|
||||
chat_type: messageObject.chat_type
|
||||
message: messageObject.message
|
||||
to_username: messageObject.to_username
|
||||
from_tz_offset: messageObject.from_tz_offset
|
||||
from_color: messageObject.from_color
|
||||
to_userid: messageObject.to_userid
|
||||
from_userid: messageObject.from_userid
|
||||
from_time: messageObject.from_time
|
||||
from_username: messageObject.from_username
|
||||
from_lang: messageObject.from_lang
|
||||
}
|
||||
}
|
||||
id = Meteor.Chat.insert(entry)
|
||||
console.log "added chat id=[#{id}]:#{messageObject.message}. Chat.size is now
|
||||
#{Meteor.Chat.find({meetingId: meetingId}).count()}"
|
||||
|
@ -56,7 +56,7 @@ Meteor.methods
|
||||
}
|
||||
|
||||
id = Meteor.Users.insert(entry)
|
||||
console.log "added user id=[#{id}]:#{user.name}. Users.size is now #{Meteor.Users.find().count()}"
|
||||
console.log "added user id=[#{id}]:#{user.name}. Users.size is now #{Meteor.Users.find({meetingId: meetingId}).count()}"
|
||||
|
||||
removeUserFromCollection: (meetingId, userId) ->
|
||||
console.log "----removing " + userId + "from " + meetingId
|
||||
|
@ -114,6 +114,15 @@ class Meteor.RedisPubSub
|
||||
if userId? and meetingId?
|
||||
Meteor.call("removeUserFromCollection", meetingId, userId)
|
||||
|
||||
if message.header?.name is "get_chat_history_reply" and message.payload?.requester_id is "nodeJSapp"
|
||||
meetingId = message.payload?.meeting_id
|
||||
for chatMessage in message.payload?.chat_history
|
||||
Meteor.call("addChatToCollection", meetingId, chatMessage)
|
||||
|
||||
if message.header?.name is "send_public_chat_message"
|
||||
messageObject = message.payload?.message
|
||||
meetingId = message.payload?.meeting_id
|
||||
Meteor.call("addChatToCollection", meetingId, messageObject)
|
||||
|
||||
publish: (channel, message) ->
|
||||
console.log "Publishing channel=#{channel}, message=#{JSON.stringify(message)}"
|
||||
|
Loading…
Reference in New Issue
Block a user