Skip to content

Commit

Permalink
Remove whitelist after unsubmit
Browse files Browse the repository at this point in the history
  • Loading branch information
ketphan02 committed Mar 31, 2024
1 parent 0b73e9f commit ccd0b8a
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/app/api/video/submit/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,45 @@ export async function DELETE(req: NextRequest) {
return NextResponse.json({ error: 'Forbidden' }, { status: 403 })
}

// Get submission box managers and owners
const requestedSubmissionManagers = (await prisma.submissionBoxManager.findMany({
where: {
submissionBoxId: {
in: submissionBoxIds,
},
},
include: {
user: {
select: {
id: true,
},
},
},
})).map(({ user }) => user.id)

const whitelistedUserIds = (await prisma.videoWhitelistedUser.findMany({
where: {
whitelistedUserId: {
in: requestedSubmissionManagers,
},
},
select: {
whitelistedUserId: true,
},
})).map(({ whitelistedUserId }) => whitelistedUserId)

// Remove whitelisted users
await prisma.videoWhitelistedUser.deleteMany({
where: {
whitelistedUserId: {
in: whitelistedUserIds,
},
whitelistedVideo: {
videoId: videoId,
},
},
})

// Delete any SubmittedVideos if they exist
await prisma.submittedVideo.deleteMany({
where: {
Expand Down

0 comments on commit ccd0b8a

Please sign in to comment.