mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-02 21:59:00 +02:00
Merge pull request #28098 from overleaf/em-dsmp-chat-event
Send a DSMP event when a chat message is sent GitOrigin-RevId: 062476676c91a4edf3d6f837d60ad16c7f912771
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const { expressify } = require('@overleaf/promise-utils')
|
||||
const Modules = require('../../infrastructure/Modules')
|
||||
const ChatApiHandler = require('./ChatApiHandler')
|
||||
const EditorRealTimeController = require('../Editor/EditorRealTimeController')
|
||||
const SessionManager = require('../Authentication/SessionManager')
|
||||
@@ -24,6 +25,13 @@ async function sendMessage(req, res) {
|
||||
message.user = UserInfoController.formatPersonalInfo(user)
|
||||
message.clientId = clientId
|
||||
EditorRealTimeController.emitToRoom(projectId, 'new-chat-message', message)
|
||||
|
||||
await Modules.promises.hooks.fire('chatMessageSent', {
|
||||
projectId,
|
||||
userId,
|
||||
messageId: message.id,
|
||||
})
|
||||
|
||||
res.sendStatus(204)
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,13 @@ describe('ChatController', function () {
|
||||
promises: {},
|
||||
}
|
||||
this.UserInfoController = {}
|
||||
this.Modules = {
|
||||
promises: {
|
||||
hooks: {
|
||||
fire: sinon.stub().resolves(),
|
||||
},
|
||||
},
|
||||
}
|
||||
this.ChatController = SandboxedModule.require(MODULE_PATH, {
|
||||
requires: {
|
||||
'@overleaf/settings': this.settings,
|
||||
@@ -30,6 +37,7 @@ describe('ChatController', function () {
|
||||
'../Authentication/SessionManager': this.SessionManager,
|
||||
'../User/UserInfoManager': this.UserInfoManager,
|
||||
'../User/UserInfoController': this.UserInfoController,
|
||||
'../../infrastructure/Modules': this.Modules,
|
||||
},
|
||||
})
|
||||
this.req = {
|
||||
|
||||
Reference in New Issue
Block a user