Bladeren bron

[web] remove runtime migration for fixing collaborator lists on projects (#26581)

GitOrigin-RevId: f6a4c142e010e168c79b59cb96dddb147093d4a0
Jakob Ackermann 1 jaar geleden
bovenliggende
commit
886bad1071

+ 0 - 26
services/web/app/src/Features/Collaborators/CollaboratorsHandler.js

@@ -27,33 +27,9 @@ module.exports = {
     convertTrackChangesToExplicitFormat,
   },
 }
-// Forces null pendingReviewer_refs, readOnly_refs, and reviewer_refs to
-// be empty arrays to avoid errors during $pull ops
-// See https://github.com/overleaf/internal/issues/24610
-async function fixNullCollaboratorRefs(projectId) {
-  // Temporary cleanup for the case where pendingReviewer_refs is null
-  await Project.updateOne(
-    { _id: projectId, pendingReviewer_refs: { $type: 'null' } },
-    { $set: { pendingReviewer_refs: [] } }
-  ).exec()
-
-  // Temporary cleanup for the case where readOnly_refs is null
-  await Project.updateOne(
-    { _id: projectId, readOnly_refs: { $type: 'null' } },
-    { $set: { readOnly_refs: [] } }
-  ).exec()
-
-  // Temporary cleanup for the case where reviewer_refs is null
-  await Project.updateOne(
-    { _id: projectId, reviewer_refs: { $type: 'null' } },
-    { $set: { reviewer_refs: [] } }
-  ).exec()
-}
 
 async function removeUserFromProject(projectId, userId) {
   try {
-    await fixNullCollaboratorRefs(projectId)
-
     await Project.updateOne(
       { _id: projectId },
       {
@@ -306,8 +282,6 @@ async function setCollaboratorPrivilegeLevel(
   }
   let update
 
-  await fixNullCollaboratorRefs(projectId)
-
   switch (privilegeLevel) {
     case PrivilegeLevels.READ_AND_WRITE: {
       update = {

+ 0 - 56
services/web/test/unit/src/Collaborators/CollaboratorsHandlerTests.js

@@ -68,46 +68,6 @@ describe('CollaboratorsHandler', function () {
         './CollaboratorsGetter': this.CollaboratorsGetter,
       },
     })
-
-    // Helper function to set up mock expectations for null reference cleanup
-    this.expectNullReferenceCleanup = projectId => {
-      this.ProjectMock.expects('updateOne')
-        .withArgs(
-          {
-            _id: projectId,
-            pendingReviewer_refs: { $type: 'null' },
-          },
-          {
-            $set: { pendingReviewer_refs: [] },
-          }
-        )
-        .chain('exec')
-        .resolves()
-      this.ProjectMock.expects('updateOne')
-        .withArgs(
-          {
-            _id: projectId,
-            readOnly_refs: { $type: 'null' },
-          },
-          {
-            $set: { readOnly_refs: [] },
-          }
-        )
-        .chain('exec')
-        .resolves()
-      this.ProjectMock.expects('updateOne')
-        .withArgs(
-          {
-            _id: projectId,
-            reviewer_refs: { $type: 'null' },
-          },
-          {
-            $set: { reviewer_refs: [] },
-          }
-        )
-        .chain('exec')
-        .resolves()
-    }
   })
 
   afterEach(function () {
@@ -117,7 +77,6 @@ describe('CollaboratorsHandler', function () {
   describe('removeUserFromProject', function () {
     describe('a non-archived project', function () {
       it('should remove the user from mongo', async function () {
-        this.expectNullReferenceCleanup(this.project._id)
         this.ProjectMock.expects('updateOne')
           .withArgs(
             {
@@ -433,7 +392,6 @@ describe('CollaboratorsHandler', function () {
         'token-read-only-1',
       ]
       for (const projectId of expectedProjects) {
-        this.expectNullReferenceCleanup(projectId)
         this.ProjectMock.expects('updateOne')
           .withArgs(
             {
@@ -596,8 +554,6 @@ describe('CollaboratorsHandler', function () {
 
   describe('setCollaboratorPrivilegeLevel', function () {
     it('sets a collaborator to read-only', async function () {
-      this.expectNullReferenceCleanup(this.project._id)
-
       this.ProjectMock.expects('updateOne')
         .withArgs(
           {
@@ -628,8 +584,6 @@ describe('CollaboratorsHandler', function () {
     })
 
     it('sets a collaborator to read-write', async function () {
-      this.expectNullReferenceCleanup(this.project._id)
-
       this.ProjectMock.expects('updateOne')
         .withArgs(
           {
@@ -669,8 +623,6 @@ describe('CollaboratorsHandler', function () {
         })
       })
       it('should correctly update the project', async function () {
-        this.expectNullReferenceCleanup(this.project._id)
-
         this.ProjectMock.expects('updateOne')
           .withArgs(
             {
@@ -714,8 +666,6 @@ describe('CollaboratorsHandler', function () {
         })
       })
       it('should correctly update the project', async function () {
-        this.expectNullReferenceCleanup(this.project._id)
-
         this.ProjectMock.expects('updateOne')
           .withArgs(
             {
@@ -748,8 +698,6 @@ describe('CollaboratorsHandler', function () {
     })
 
     it('sets a collaborator to read-only as a pendingEditor', async function () {
-      this.expectNullReferenceCleanup(this.project._id)
-
       this.ProjectMock.expects('updateOne')
         .withArgs(
           {
@@ -783,8 +731,6 @@ describe('CollaboratorsHandler', function () {
     })
 
     it('sets a collaborator to read-only as a pendingReviewer', async function () {
-      this.expectNullReferenceCleanup(this.project._id)
-
       this.ProjectMock.expects('updateOne')
         .withArgs(
           {
@@ -818,8 +764,6 @@ describe('CollaboratorsHandler', function () {
     })
 
     it('throws a NotFoundError if the project or collaborator does not exist', async function () {
-      this.expectNullReferenceCleanup(this.project._id)
-
       this.ProjectMock.expects('updateOne')
         .chain('exec')
         .resolves({ matchedCount: 0 })