Merge pull request #24618 from overleaf/rh-null-pending-reviewer

Handle null readOnly_refs in CollaboratorsHandler

GitOrigin-RevId: b718c4a1b5216a42920909615a0f3c2fe0a16bdb
This commit is contained in:
roo hutton
2025-04-02 08:05:10 +00:00
committed by Copybot
parent 774292d8ba
commit 0c6c61b654
2 changed files with 54 additions and 0 deletions
@@ -39,6 +39,12 @@ async function removeUserFromProject(projectId, userId) {
{ $set: { pendingReviewer_refs: [] } }
).exec()
// Temporary workaround for the case where readOnly_refs is null
await Project.updateOne(
{ _id: projectId, readOnly_refs: { $type: 'null' } },
{ $set: { readOnly_refs: [] } }
).exec()
// Deal with the old type of boolean value for archived
// In order to clear it
if (typeof project.archived === 'boolean') {
@@ -112,6 +112,18 @@ describe('CollaboratorsHandler', function () {
)
.chain('exec')
.resolves()
this.ProjectMock.expects('updateOne')
.withArgs(
{
_id: this.project._id,
readOnly_refs: { $type: 'null' },
},
{
$set: { readOnly_refs: [] },
}
)
.chain('exec')
.resolves()
this.ProjectMock.expects('updateOne')
.withArgs(
{
@@ -166,6 +178,18 @@ describe('CollaboratorsHandler', function () {
)
.chain('exec')
.resolves()
this.ProjectMock.expects('updateOne')
.withArgs(
{
_id: this.oldArchivedProject._id,
readOnly_refs: { $type: 'null' },
},
{
$set: { readOnly_refs: [] },
}
)
.chain('exec')
.resolves()
this.ProjectMock.expects('updateOne')
.withArgs(
{
@@ -218,6 +242,18 @@ describe('CollaboratorsHandler', function () {
)
.chain('exec')
.resolves()
this.ProjectMock.expects('updateOne')
.withArgs(
{
_id: this.archivedProject._id,
readOnly_refs: { $type: 'null' },
},
{
$set: { readOnly_refs: [] },
}
)
.chain('exec')
.resolves()
this.ProjectMock.expects('updateOne')
.withArgs(
{
@@ -517,6 +553,18 @@ describe('CollaboratorsHandler', function () {
)
.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(
{