Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

feat: share newly created subcollection with users from parent collection

Dino Gržinićcddfc5dba628
diff --git a/apps/web/lib/api/controllers/collections/postCollection.ts b/apps/web/lib/api/controllers/collections/postCollection.ts
index dc4e612a..c6822179 100644
--- a/apps/web/lib/api/controllers/collections/postCollection.ts
+++ b/apps/web/lib/api/controllers/collections/postCollection.ts
@@ -24,6 +24,8 @@ export default async function postCollection(
const collection = dataValidation.data;
+ let parentCollectionMembers: UsersAndCollections[] = [];
+
if (collection.parentId) {
const findParentCollection = await prisma.collection.findUnique({
where: {
@@ -31,8 +33,14 @@ export default async function postCollection(
},
select: {
ownerId: true,
+ members: true,
},
});
+
+ if (findParentCollection) {
+ parentCollectionMembers =
+ findParentCollection.members as UsersAndCollections[];
+ }
const collectionIsAccessible = await getPermission({
userId: userId,
collectionId: collection.parentId,
@@ -59,6 +67,14 @@ export default async function postCollection(
color: collection.color,
icon: collection.icon,
iconWeight: collection.iconWeight,
+ members: {
+ create: parentCollectionMembers.map((member) => ({
+ userId: member.userId,
+ canCreate: member.canCreate,
+ canUpdate: member.canUpdate,
+ canDelete: member.canDelete,
+ })),
+ },
parent: collection.parentId
? {
connect: {