From b7b85cc2673f1d90a08fcc651dd519094e0ec8de Mon Sep 17 00:00:00 2001 From: seaerchin Date: Fri, 31 Mar 2023 17:25:29 +0800 Subject: [PATCH] fix(review): check for migrated site but not site members --- src/routes/v2/authenticated/review.ts | 46 ++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/src/routes/v2/authenticated/review.ts b/src/routes/v2/authenticated/review.ts index a4430b0e9..998928a62 100644 --- a/src/routes/v2/authenticated/review.ts +++ b/src/routes/v2/authenticated/review.ts @@ -104,6 +104,13 @@ export class ReviewsRouter { if (!site && doesUnmigratedSiteExist) return res.status(200).json({ message: "Unmigrated site" }) + const siteMembers = await this.collaboratorsService.list(siteName) + // NOTE: This is an initial migrated site but + // we haven't migrated the users. + if (siteMembers.length === 0 && site) { + return res.status(200).json({ message: "Unmigrated users" }) + } + // Check if they have access to site const possibleSiteMember = await this.identityUsersService.getSiteMember( userWithSiteSessionData.isomerUserId, @@ -111,7 +118,7 @@ export class ReviewsRouter { ) if (!possibleSiteMember) { - return res.status(404).send() + return res.status(404).json({ message: "asdf " }) } const files = await this.reviewRequestService.compareDiff( @@ -267,6 +274,13 @@ export class ReviewsRouter { if (!site && doesUnmigratedSiteExist) return res.status(200).json({ message: "Unmigrated site" }) + const siteMembers = await this.collaboratorsService.list(siteName) + // NOTE: This is an initial migrated site but + // we haven't migrated the users. + if (siteMembers.length === 0 && site) { + return res.status(200).json({ message: "Unmigrated users" }) + } + if (!site) { logger.error({ message: "Invalid site requested", @@ -439,8 +453,16 @@ export class ReviewsRouter { userWithSiteSessionData ) - if (!site && doesUnmigratedSiteExist) + if (!site && doesUnmigratedSiteExist) { return res.status(200).json({ message: "Unmigrated site" }) + } + + const siteMembers = await this.collaboratorsService.list(siteName) + // NOTE: This is an initial migrated site but + // we haven't migrated the users. + if (siteMembers.length === 0 && site) { + return res.status(200).json({ message: "Unmigrated users" }) + } if (!site) { logger.error({ @@ -810,8 +832,16 @@ export class ReviewsRouter { userWithSiteSessionData ) - if (!site && doesUnmigratedSiteExist) + if (!site && doesUnmigratedSiteExist) { return res.status(200).json({ message: "Unmigrated site" }) + } + + const siteMembers = await this.collaboratorsService.list(siteName) + // NOTE: This is an initial migrated site but + // we haven't migrated the users. + if (siteMembers.length === 0 && site) { + return res.status(200).json({ message: "Unmigrated users" }) + } if (!site) { logger.error({ @@ -1211,8 +1241,16 @@ export class ReviewsRouter { userWithSiteSessionData ) - if (!site && doesUnmigratedSiteExist) + if (!site && doesUnmigratedSiteExist) { return res.status(200).json({ message: "Unmigrated site" }) + } + + const siteMembers = await this.collaboratorsService.list(siteName) + // NOTE: This is an initial migrated site but + // we haven't migrated the users. + if (siteMembers.length === 0 && site) { + return res.status(200).json({ message: "Unmigrated users" }) + } if (!site) { logger.error({