added collaboration mode for collections
This commit is contained in:
@@ -7,15 +7,12 @@ import { prisma } from "@/lib/api/db";
|
||||
import { ExtendedLink } from "@/types/global";
|
||||
import fs from "fs";
|
||||
import { Link, UsersAndCollections } from "@prisma/client";
|
||||
import hasAccessToCollection from "@/lib/api/hasAccessToCollection";
|
||||
import getPermission from "@/lib/api/getPermission";
|
||||
|
||||
export default async function (link: ExtendedLink, userId: number) {
|
||||
if (!link) return { response: "Please choose a valid link.", status: 401 };
|
||||
|
||||
const collectionIsAccessible = await hasAccessToCollection(
|
||||
userId,
|
||||
link.collectionId
|
||||
);
|
||||
const collectionIsAccessible = await getPermission(userId, link.collectionId);
|
||||
|
||||
const memberHasAccess = collectionIsAccessible?.members.some(
|
||||
(e: UsersAndCollections) => e.userId === userId && e.canDelete
|
||||
|
||||
@@ -9,7 +9,7 @@ import getTitle from "../../getTitle";
|
||||
import archive from "../../archive";
|
||||
import { Link, UsersAndCollections } from "@prisma/client";
|
||||
import AES from "crypto-js/aes";
|
||||
import hasAccessToCollection from "@/lib/api/hasAccessToCollection";
|
||||
import getPermission from "@/lib/api/getPermission";
|
||||
|
||||
export default async function (link: ExtendedLink, userId: number) {
|
||||
link.collection.name = link.collection.name.trim();
|
||||
@@ -21,7 +21,7 @@ export default async function (link: ExtendedLink, userId: number) {
|
||||
}
|
||||
|
||||
if (link.collection.ownerId) {
|
||||
const collectionIsAccessible = await hasAccessToCollection(
|
||||
const collectionIsAccessible = await getPermission(
|
||||
userId,
|
||||
link.collection.id
|
||||
);
|
||||
|
||||
@@ -6,15 +6,12 @@
|
||||
import { prisma } from "@/lib/api/db";
|
||||
import { ExtendedLink } from "@/types/global";
|
||||
import { Link, UsersAndCollections } from "@prisma/client";
|
||||
import hasAccessToCollection from "@/lib/api/hasAccessToCollection";
|
||||
import getPermission from "@/lib/api/getPermission";
|
||||
|
||||
export default async function (link: ExtendedLink, userId: number) {
|
||||
if (!link) return { response: "Please choose a valid link.", status: 401 };
|
||||
|
||||
const collectionIsAccessible = await hasAccessToCollection(
|
||||
userId,
|
||||
link.collectionId
|
||||
);
|
||||
const collectionIsAccessible = await getPermission(userId, link.collectionId);
|
||||
|
||||
const memberHasAccess = collectionIsAccessible?.members.some(
|
||||
(e: UsersAndCollections) => e.userId === userId && e.canUpdate
|
||||
|
||||
Reference in New Issue
Block a user