1
0
Fork 0
mirror of https://github.com/overleaf/overleaf.git synced 2024-12-22 18:21:59 +00:00
overleaf/services/web/app/coffee/Features/Chat/ChatController.coffee

29 lines
1 KiB
CoffeeScript
Raw Normal View History

2014-07-04 12:05:55 +00:00
ChatHandler = require("./ChatHandler")
EditorRealTimeController = require("../Editor/EditorRealTimeController")
2014-07-04 12:29:59 +00:00
logger = require("logger-sharelatex")
2014-07-04 12:05:55 +00:00
module.exports =
sendMessage: (req, res)->
2014-07-14 21:11:41 +00:00
project_id = req.params.Project_id
user_id = req.session.user._id
messageContent = req.body.content
ChatHandler.sendMessage project_id, user_id, messageContent, (err, builtMessge)->
2014-07-04 12:29:59 +00:00
if err?
logger.err err:err, project_id:project_id, user_id:user_id, messageContent:messageContent, "problem sending message to chat api"
return res.send(500)
EditorRealTimeController.emitToRoom project_id, "new-chat-message", builtMessge, (err)->
res.send()
2014-07-04 12:05:55 +00:00
getMessages: (req, res)->
2014-07-14 21:11:41 +00:00
project_id = req.params.Project_id
2014-07-15 17:25:12 +00:00
query = req.query
logger.log project_id:project_id, query:query, "getting messages"
ChatHandler.getMessages project_id, query, (err, messages)->
2014-07-04 12:29:59 +00:00
if err?
logger.err err:err, query:query, "problem getting messages from chat api"
return res.send 500
logger.log messages:messages, "sending messages to client"
res.send messages