From 5358682a8cfbd12d93a4e9962f7a9f0440c42c19 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 2 Nov 2025 20:48:17 +0000 Subject: feat(rss): Add import tags from RSS feed categories (#2031) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(feeds): Add import tags from RSS feed categories - Add importTags boolean field to rssFeedsTable schema (default: false) - Create database migration 0063_add_import_tags_to_feeds.sql - Update zod schemas (zFeedSchema, zNewFeedSchema, zUpdateFeedSchema) to include importTags - Update Feed model to handle importTags in create and update methods - Update feedWorker to: - Read title and categories from RSS parser - Attach categories as tags to bookmarks when importTags is enabled - Log warnings if tag attachment fails Resolves #1996 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Mohamed Bassem * feat(web): Add importTags option to feed settings UI - Add importTags toggle to FeedsEditorDialog (create feed) - Add importTags toggle to EditFeedDialog (edit feed) - Display as a bordered switch control with descriptive text - Defaults to false for new feeds Co-authored-by: Mohamed Bassem * fix migration * remove extra migration --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Mohamed Bassem --- apps/web/components/settings/FeedSettings.tsx | 47 +++++++++++++++++++++++++++ apps/workers/workers/feedWorker.ts | 29 +++++++++++++++++ 2 files changed, 76 insertions(+) (limited to 'apps') diff --git a/apps/web/components/settings/FeedSettings.tsx b/apps/web/components/settings/FeedSettings.tsx index f14e0841..23b639e4 100644 --- a/apps/web/components/settings/FeedSettings.tsx +++ b/apps/web/components/settings/FeedSettings.tsx @@ -71,6 +71,7 @@ export function FeedsEditorDialog() { name: "", url: "", enabled: true, + importTags: false, }, }); @@ -142,6 +143,28 @@ export function FeedsEditorDialog() { ); }} /> + { + return ( + +
+ Import Tags +
+ Automatically import categories from RSS feed as tags +
+
+ + + +
+ ); + }} + /> @@ -177,6 +200,7 @@ export function EditFeedDialog({ feed }: { feed: ZFeed }) { feedId: feed.id, name: feed.name, url: feed.url, + importTags: feed.importTags, }); } }, [open]); @@ -196,6 +220,7 @@ export function EditFeedDialog({ feed }: { feed: ZFeed }) { feedId: feed.id, name: feed.name, url: feed.url, + importTags: feed.importTags, }, }); return ( @@ -266,6 +291,28 @@ export function EditFeedDialog({ feed }: { feed: ZFeed }) { ); }} /> + { + return ( + +
+ Import Tags +
+ Automatically import categories from RSS feed as tags +
+
+ + + +
+ ); + }} + /> diff --git a/apps/workers/workers/feedWorker.ts b/apps/workers/workers/feedWorker.ts index f86e7424..0dfc5399 100644 --- a/apps/workers/workers/feedWorker.ts +++ b/apps/workers/workers/feedWorker.ts @@ -154,6 +154,8 @@ async function run(req: DequeuedJob) { id: z.coerce.string(), link: z.string().optional(), guid: z.string().optional(), + title: z.string().optional(), + categories: z.array(z.string()).optional(), }); const feedItems = unparseFeedData.items @@ -209,11 +211,38 @@ async function run(req: DequeuedJob) { trpcClient.bookmarks.createBookmark({ type: BookmarkTypes.LINK, url: item.link!, + title: item.title, source: "rss", }), ), ); + // If importTags is enabled, attach categories as tags to the created bookmarks + if (feed.importTags) { + await Promise.allSettled( + newEntries.map(async (item, idx) => { + const bookmark = createdBookmarks[idx]; + if ( + bookmark.status === "fulfilled" && + item.categories && + item.categories.length > 0 + ) { + try { + await trpcClient.bookmarks.updateTags({ + bookmarkId: bookmark.value.id, + attach: item.categories.map((tagName) => ({ tagName })), + detach: [], + }); + } catch (error) { + logger.warn( + `[feed][${jobId}] Failed to attach tags to bookmark ${bookmark.value.id}: ${error}`, + ); + } + } + }), + ); + } + // It's ok if this is not transactional as the bookmarks will get linked in the next iteration. await db .insert(rssFeedImportsTable) -- cgit v1.2.3-70-g09d2