aboutsummaryrefslogtreecommitdiffstats
path: root/packages/trpc
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-10-06 12:26:31 +0000
committerMohamedBassem <me@mbassem.com>2024-10-06 12:26:31 +0000
commitdb2d346cd6c265d8e7c69383c6de03bf5f6252f0 (patch)
treebe8a7987190c292d96a52c8a84f83cb3566801e6 /packages/trpc
parente6d4ff9e9c5e3de8cd2a4abf8195e2e40d21317e (diff)
downloadkarakeep-db2d346cd6c265d8e7c69383c6de03bf5f6252f0.tar.zst
refactor: Include userId in the assets table
Diffstat (limited to 'packages/trpc')
-rw-r--r--packages/trpc/routers/bookmarks.test.ts4
-rw-r--r--packages/trpc/routers/bookmarks.ts1
2 files changed, 5 insertions, 0 deletions
diff --git a/packages/trpc/routers/bookmarks.test.ts b/packages/trpc/routers/bookmarks.test.ts
index 9fcbec52..d6a7bc27 100644
--- a/packages/trpc/routers/bookmarks.test.ts
+++ b/packages/trpc/routers/bookmarks.test.ts
@@ -344,6 +344,7 @@ describe("Bookmark Routes", () => {
test<CustomTestContext>("mutate assets", async ({ apiCallers, db }) => {
const api = apiCallers[0].bookmarks;
+ const userId = await apiCallers[0].users.whoami().then((u) => u.id);
const bookmark = await api.createBookmark({
url: "https://google.com",
@@ -354,16 +355,19 @@ describe("Bookmark Routes", () => {
id: "asset1",
assetType: AssetTypes.LINK_SCREENSHOT,
bookmarkId: bookmark.id,
+ userId,
}),
db.insert(assets).values({
id: "asset2",
assetType: AssetTypes.LINK_BANNER_IMAGE,
bookmarkId: bookmark.id,
+ userId,
}),
db.insert(assets).values({
id: "asset3",
assetType: AssetTypes.LINK_FULL_PAGE_ARCHIVE,
bookmarkId: bookmark.id,
+ userId,
}),
]);
diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts
index 895e072a..b1491a61 100644
--- a/packages/trpc/routers/bookmarks.ts
+++ b/packages/trpc/routers/bookmarks.ts
@@ -853,6 +853,7 @@ export const bookmarksAppRouter = router({
id: input.asset.id,
assetType: mapSchemaAssetTypeToDB(input.asset.assetType),
bookmarkId: input.bookmarkId,
+ userId: ctx.user.id,
})
.returning();
return input.asset;