Skip to content

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

fix(import): save pinnedLinks from Linkwarden export json

keizie90657566863c
diff --git a/lib/api/controllers/migration/importFromLinkwarden.ts b/lib/api/controllers/migration/importFromLinkwarden.ts
index 202b1148..8d0544c7 100644
--- a/lib/api/controllers/migration/importFromLinkwarden.ts
+++ b/lib/api/controllers/migration/importFromLinkwarden.ts
@@ -61,7 +61,7 @@ export default async function importFromLinkwarden(
}
}
- await prisma.link.create({
+ const newLink = await prisma.link.create({
data: {
url: link.url?.trim().slice(0, 254),
name: link.name?.trim().slice(0, 254),
@@ -98,6 +98,19 @@ export default async function importFromLinkwarden(
},
},
});
+ // Import pinnedLinks
+ data?.pinnedLinks.forEach(async (pinnedLink) => {
+ if (pinnedLink.url === newLink.url) {
+ await prisma.link.update({
+ where: {
+ id: newLink.id,
+ },
+ data: {
+ pinnedBy: { connect: { id: userId } },
+ },
+ });
+ }
+ });
}
}
},
diff --git a/types/global.ts b/types/global.ts
index 39da331d..2f12b511 100644
--- a/types/global.ts
+++ b/types/global.ts
@@ -108,6 +108,7 @@ interface CollectionIncludingLinks extends Collection {
export interface Backup extends Omit<User, "password" | "id"> {
collections: CollectionIncludingLinks[];
+ pinnedLinks: LinksIncludingTags[];
}
export type MigrationRequest = {