fix not being able to delete orphaned content
This commit is contained in:
parent
5db0a9edc3
commit
4f6298d380
1 changed files with 9 additions and 15 deletions
|
@ -166,29 +166,23 @@ export async function DELETE(request: NextRequest, {params}: {params: {content:s
|
|||
status: 400
|
||||
});
|
||||
|
||||
let jamParent = await db
|
||||
let jamParentOwner, jamParent = await db
|
||||
.selectFrom('jams')
|
||||
.where('jams.id', '=', deletingContent.jam_id)
|
||||
.select('author_id')
|
||||
.executeTakeFirst();
|
||||
|
||||
if (jamParent == null) return new Response('', {
|
||||
status: 500
|
||||
});
|
||||
|
||||
let jamParentOwner = await db
|
||||
.selectFrom('users')
|
||||
.where('users.id', '=', jamParent.author_id)
|
||||
.select('id')
|
||||
.executeTakeFirst();
|
||||
|
||||
if (jamParentOwner == null) return new Response('', {
|
||||
status: 500
|
||||
});
|
||||
if (jamParent != null) {
|
||||
jamParentOwner = await db
|
||||
.selectFrom('users')
|
||||
.where('users.id', '=', jamParent.author_id)
|
||||
.select('id')
|
||||
.executeTakeFirst();
|
||||
}
|
||||
|
||||
if (
|
||||
!existingUser?.admin
|
||||
&& jamParentOwner.id != existingUser.id
|
||||
&& (jamParentOwner?.id != existingUser.id)
|
||||
&& deletingContent.author_id != existingUser.id
|
||||
) return new Response('you are NOT that guy.', {
|
||||
status: 401
|
||||
|
|
Loading…
Reference in a new issue