Просмотр исходного кода

[web] emit project:membership:changed when removing self from project (#33143)

GitOrigin-RevId: 5a101add69e0077f667f98f5b95c2476ad3085d4
Kristina 5 месяцев назад
Родитель
Сommit
fdc939fe0a

+ 3 - 0
services/web/app/src/Features/Collaborators/CollaboratorsController.mjs

@@ -63,6 +63,9 @@ async function removeSelfFromProject(req, res, next) {
   const projectId = req.params.Project_id
   const projectId = req.params.Project_id
   const userId = SessionManager.getLoggedInUserId(req.session)
   const userId = SessionManager.getLoggedInUserId(req.session)
   await _removeUserIdFromProject(projectId, userId)
   await _removeUserIdFromProject(projectId, userId)
+  EditorRealTimeController.emitToRoom(projectId, 'project:membership:changed', {
+    members: true,
+  })
 
 
   ProjectAuditLogHandler.addEntryInBackground(
   ProjectAuditLogHandler.addEntryInBackground(
     projectId,
     projectId,

+ 8 - 0
services/web/test/unit/src/Collaborators/CollaboratorsController.test.mjs

@@ -274,6 +274,14 @@ describe('CollaboratorsController', function () {
       ctx.res.sendStatus.calledWith(204).should.equal(true)
       ctx.res.sendStatus.calledWith(204).should.equal(true)
     })
     })
 
 
+    it('should emit a project:membership:changed event to the project', function (ctx) {
+      expect(ctx.EditorRealTimeController.emitToRoom).to.have.been.calledWith(
+        ctx.projectId,
+        'project:membership:changed',
+        { members: true }
+      )
+    })
+
     it('should write a project audit log', function (ctx) {
     it('should write a project audit log', function (ctx) {
       ctx.ProjectAuditLogHandler.addEntryInBackground.should.have.been.calledWith(
       ctx.ProjectAuditLogHandler.addEntryInBackground.should.have.been.calledWith(
         ctx.projectId,
         ctx.projectId,