Skip to content

Commit

Permalink
fix(review): check for migrated site but not site members
Browse files Browse the repository at this point in the history
  • Loading branch information
seaerchin committed Mar 31, 2023
1 parent 9c3df90 commit b7b85cc
Showing 1 changed file with 42 additions and 4 deletions.
46 changes: 42 additions & 4 deletions src/routes/v2/authenticated/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,21 @@ 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,
siteName
)

if (!possibleSiteMember) {
return res.status(404).send()
return res.status(404).json({ message: "asdf " })
}

const files = await this.reviewRequestService.compareDiff(
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit b7b85cc

Please sign in to comment.