mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
linked chat into the editor real time contorller
This commit is contained in:
parent
86a9d08e5c
commit
0d02241b46
2 changed files with 16 additions and 2 deletions
|
@ -1,11 +1,13 @@
|
||||||
ChatHandler = require("./ChatHandler")
|
ChatHandler = require("./ChatHandler")
|
||||||
|
EditorRealTimeController = require("../Editor/EditorRealTimeController")
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
|
|
||||||
|
|
||||||
sendMessage: (project_id, user_id, messageContent, callback)->
|
sendMessage: (project_id, user_id, messageContent, callback)->
|
||||||
ChatHandler.sendMessage project_id, user_id, messageContent, (err)->
|
ChatHandler.sendMessage project_id, user_id, messageContent, (err, builtMessge)->
|
||||||
callback()
|
EditorRealTimeController.emitToRoom project_id, "new-chat-message", builtMessge, (err)->
|
||||||
|
callback(err)
|
||||||
|
|
||||||
getMessages: (project_id, query, callback)->
|
getMessages: (project_id, query, callback)->
|
||||||
ChatHandler.getMessages project_id, query, (err)->
|
ChatHandler.getMessages project_id, query, (err)->
|
||||||
|
|
|
@ -15,10 +15,13 @@ describe "ChatController", ->
|
||||||
sendMessage:sinon.stub()
|
sendMessage:sinon.stub()
|
||||||
getMessages:sinon.stub()
|
getMessages:sinon.stub()
|
||||||
|
|
||||||
|
@EditorRealTimeController =
|
||||||
|
emitToRoom:sinon.stub().callsArgWith(3)
|
||||||
@ChatController = SandboxedModule.require modulePath, requires:
|
@ChatController = SandboxedModule.require modulePath, requires:
|
||||||
"settings-sharelatex":@settings
|
"settings-sharelatex":@settings
|
||||||
"logger-sharelatex": log:->
|
"logger-sharelatex": log:->
|
||||||
"./ChatHandler":@ChatHandler
|
"./ChatHandler":@ChatHandler
|
||||||
|
"../Editor/EditorRealTimeController":@EditorRealTimeController
|
||||||
@query =
|
@query =
|
||||||
before:"some time"
|
before:"some time"
|
||||||
|
|
||||||
|
@ -32,6 +35,15 @@ describe "ChatController", ->
|
||||||
@ChatHandler.sendMessage.calledWith(@project_id, @user_id, @messageContent).should.equal true
|
@ChatHandler.sendMessage.calledWith(@project_id, @user_id, @messageContent).should.equal true
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
it "should tell the editor real time controller about the update with the data from the chat handler", (done)->
|
||||||
|
@chatMessage =
|
||||||
|
content:"hello world"
|
||||||
|
@ChatHandler.sendMessage.callsArgWith(3, null, @chatMessage)
|
||||||
|
@ChatController.sendMessage @project_id, @user_id, @messageContent, (err)=>
|
||||||
|
@EditorRealTimeController.emitToRoom.calledWith(@project_id, "new-chat-message", @chatMessage).should.equal true
|
||||||
|
done()
|
||||||
|
|
||||||
|
|
||||||
describe "getMessages", ->
|
describe "getMessages", ->
|
||||||
|
|
||||||
it "should tell the chat handler about the request", (done)->
|
it "should tell the chat handler about the request", (done)->
|
||||||
|
|
Loading…
Reference in a new issue