diff options
Diffstat (limited to 'packages/trpc')
| -rw-r--r-- | packages/trpc/routers/bookmarks.ts | 14 | ||||
| -rw-r--r-- | packages/trpc/routers/feeds.ts | 20 |
2 files changed, 34 insertions, 0 deletions
diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts index 9a27c25a..4e58bcdc 100644 --- a/packages/trpc/routers/bookmarks.ts +++ b/packages/trpc/routers/bookmarks.ts @@ -18,6 +18,7 @@ import { bookmarksInLists, bookmarkTags, bookmarkTexts, + rssFeedImportsTable, tagsOnBookmarks, } from "@hoarder/db/schema"; import { deleteAsset } from "@hoarder/shared/assetdb"; @@ -591,6 +592,19 @@ export const bookmarksAppRouter = router({ ), ) : undefined, + input.rssFeedId !== undefined + ? exists( + ctx.db + .select() + .from(rssFeedImportsTable) + .where( + and( + eq(rssFeedImportsTable.bookmarkId, bookmarks.id), + eq(rssFeedImportsTable.rssFeedId, input.rssFeedId), + ), + ), + ) + : undefined, input.listId !== undefined ? exists( ctx.db diff --git a/packages/trpc/routers/feeds.ts b/packages/trpc/routers/feeds.ts index a8025dfb..e5520474 100644 --- a/packages/trpc/routers/feeds.ts +++ b/packages/trpc/routers/feeds.ts @@ -82,6 +82,26 @@ export const feedsAppRouter = router({ } return feed[0]; }), + get: authedProcedure + .input( + z.object({ + feedId: z.string(), + }), + ) + .output(zFeedSchema) + .use(ensureFeedOwnership) + .query(async ({ ctx, input }) => { + const feed = await ctx.db.query.rssFeedsTable.findFirst({ + where: and( + eq(rssFeedsTable.userId, ctx.user.id), + eq(rssFeedsTable.id, input.feedId), + ), + }); + if (!feed) { + throw new TRPCError({ code: "NOT_FOUND" }); + } + return feed; + }), list: authedProcedure .output(z.object({ feeds: z.array(zFeedSchema) })) .query(async ({ ctx }) => { |
