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:
Eric Mc Sween
2025-08-25 10:27:32 -04:00
committed by Copybot
parent aa8bef1e8d
commit b2df393bbb
2 changed files with 16 additions and 0 deletions
@@ -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 = {