mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
581d9ec925
- removed lots of console.logs - working on the auto scrol, doesn't quite work yet
28 lines
1 KiB
CoffeeScript
28 lines
1 KiB
CoffeeScript
ChatHandler = require("./ChatHandler")
|
|
EditorRealTimeController = require("../Editor/EditorRealTimeController")
|
|
logger = require("logger-sharelatex")
|
|
|
|
module.exports =
|
|
|
|
|
|
sendMessage: (req, res)->
|
|
{project_id} = req.params
|
|
user_id = req.session.user._id
|
|
messageContent = req.body.content
|
|
ChatHandler.sendMessage project_id, user_id, messageContent, (err, builtMessge)->
|
|
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()
|
|
|
|
getMessages: (req, res)->
|
|
{project_id} = req.params
|
|
query = req.body
|
|
logger.log project_id:project_id, query:query, "getting messages"
|
|
ChatHandler.getMessages project_id, query, (err, messages)->
|
|
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
|