diff options
| author | Mohamed Bassem <me@mbassem.com> | 2025-04-13 14:04:39 +0000 |
|---|---|---|
| committer | Mohamed Bassem <me@mbassem.com> | 2025-04-13 14:04:39 +0000 |
| commit | a4d5be3a3a031c039568b5cb4e7e2305f8e4f283 (patch) | |
| tree | c2721be51d72ea12cbe01efeee6d429de963f932 /packages/trpc/routers | |
| parent | 8c6cfc8f5fdab4bbdae41060518c08731720976a (diff) | |
| download | karakeep-a4d5be3a3a031c039568b5cb4e7e2305f8e4f283.tar.zst | |
feat: Allow editing the extracted content of an asset bookmark
Diffstat (limited to 'packages/trpc/routers')
| -rw-r--r-- | packages/trpc/routers/bookmarks.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts index fdb99257..7ad98b37 100644 --- a/packages/trpc/routers/bookmarks.ts +++ b/packages/trpc/routers/bookmarks.ts @@ -225,6 +225,7 @@ function toZodSchema(bookmark: BookmarkQueryReturnType): ZBookmark { fileName: asset.fileName, sourceUrl: asset.sourceUrl, size: assets.find((a) => a.id == asset.assetId)?.size, + content: asset.content, }; } @@ -485,6 +486,24 @@ export const bookmarksAppRouter = router({ somethingChanged = true; } + if (input.assetContent !== undefined) { + const result = await tx + .update(bookmarkAssets) + .set({ + content: input.assetContent, + }) + .where(and(eq(bookmarkAssets.id, input.bookmarkId))); + + if (result.changes == 0) { + throw new TRPCError({ + code: "BAD_REQUEST", + message: + "Attempting to set asset content for non-asset type bookmark", + }); + } + somethingChanged = true; + } + // Update common bookmark fields const commonUpdateData: Partial<{ title: string | null; @@ -861,6 +880,7 @@ export const bookmarksAppRouter = router({ fileName: row.bookmarkAssets.fileName, sourceUrl: row.bookmarkAssets.sourceUrl ?? null, size: null, // This will get filled in the asset loop + content: row.bookmarkAssets.content ?? null, }; } else { content = { |
