2014-07-04 08:05:55 -04:00
|
|
|
ChatHandler = require("./ChatHandler")
|
2014-07-04 08:20:30 -04:00
|
|
|
EditorRealTimeController = require("../Editor/EditorRealTimeController")
|
2014-07-04 08:29:59 -04:00
|
|
|
logger = require("logger-sharelatex")
|
2014-07-04 08:05:55 -04:00
|
|
|
|
|
|
|
module.exports =
|
|
|
|
|
|
|
|
|
|
|
|
sendMessage: (project_id, user_id, messageContent, callback)->
|
2014-07-04 08:20:30 -04:00
|
|
|
ChatHandler.sendMessage project_id, user_id, messageContent, (err, builtMessge)->
|
2014-07-04 08:29:59 -04:00
|
|
|
if err?
|
|
|
|
logger.err err:err, project_id:project_id, user_id:user_id, messageContent:messageContent, "problem sending message to chat api"
|
|
|
|
return callback(err)
|
2014-07-04 08:20:30 -04:00
|
|
|
EditorRealTimeController.emitToRoom project_id, "new-chat-message", builtMessge, (err)->
|
|
|
|
callback(err)
|
2014-07-04 08:05:55 -04:00
|
|
|
|
|
|
|
getMessages: (project_id, query, callback)->
|
|
|
|
ChatHandler.getMessages project_id, query, (err)->
|
2014-07-04 08:29:59 -04:00
|
|
|
if err?
|
|
|
|
logger.err err:err, query:query, "problem getting messages from chat api"
|
|
|
|
return callback(err)
|
2014-07-04 08:05:55 -04:00
|
|
|
callback()
|