aboutsummaryrefslogtreecommitdiffstats
path: root/packages/trpc
diff options
context:
space:
mode:
Diffstat (limited to 'packages/trpc')
-rw-r--r--packages/trpc/routers/bookmarks.ts20
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 = {