bigbluebutton-Github/labs/meteor-client/collections/chat.coffee

25 lines
1.0 KiB
CoffeeScript
Raw Normal View History

Meteor.methods
addChatToCollection: (meetingId, messageObject) ->
2014-08-22 04:03:31 +08:00
# manually convert time from 1.408645053653E12 to 1408645053653 if necessary
messageObject.from_time = (messageObject.from_time).toString().split('.').join("").split("E")[0]
2014-07-10 03:09:10 +08:00
entry =
meetingId: meetingId
2014-07-10 03:09:10 +08:00
message:
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
2014-07-10 03:09:10 +08:00
id = Meteor.Chat.insert(entry)
console.log "added chat id=[#{id}]:#{messageObject.message}. Chat.size is now
#{Meteor.Chat.find({meetingId: meetingId}).count()}"
sendChatMessagetoServer: (meetingId, messageObject) ->
Meteor.call "publishChatMessage", meetingId, messageObject