updated route + bug fixed
This commit is contained in:
@@ -1,35 +1,24 @@
|
||||
import { prisma } from "@/lib/api/db";
|
||||
|
||||
type Props = {
|
||||
userId?: number;
|
||||
userId: number;
|
||||
collectionId?: number;
|
||||
linkId?: number;
|
||||
isPublic?: boolean;
|
||||
};
|
||||
|
||||
export default async function getPermission({
|
||||
userId,
|
||||
collectionId,
|
||||
linkId,
|
||||
isPublic,
|
||||
}: Props) {
|
||||
if (linkId) {
|
||||
const check = await prisma.collection.findFirst({
|
||||
where: {
|
||||
[isPublic ? "OR" : "AND"]: [
|
||||
{
|
||||
id: collectionId,
|
||||
OR: [{ ownerId: userId }, { members: { some: { userId } } }],
|
||||
links: {
|
||||
some: {
|
||||
id: linkId,
|
||||
},
|
||||
},
|
||||
links: {
|
||||
some: {
|
||||
id: linkId,
|
||||
},
|
||||
{
|
||||
isPublic: isPublic ? true : undefined,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
include: { members: true },
|
||||
});
|
||||
@@ -38,15 +27,8 @@ export default async function getPermission({
|
||||
} else if (collectionId) {
|
||||
const check = await prisma.collection.findFirst({
|
||||
where: {
|
||||
[isPublic ? "OR" : "AND"]: [
|
||||
{
|
||||
id: collectionId,
|
||||
OR: [{ ownerId: userId }, { members: { some: { userId } } }],
|
||||
},
|
||||
{
|
||||
isPublic: isPublic ? true : undefined,
|
||||
},
|
||||
],
|
||||
id: collectionId,
|
||||
OR: [{ ownerId: userId }, { members: { some: { userId } } }],
|
||||
},
|
||||
include: { members: true },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user