From c56cf4e24f6134547fb9c5b58eb20840f5083e9e Mon Sep 17 00:00:00 2001 From: Andrii Mokhovyk Date: Sun, 18 Jan 2026 16:36:49 +0200 Subject: feat(rules): add "Title Contains" condition to Rule Engine (#1670) (#2354) * feat(rules): add "Title Contains" condition to Rule Engine (#1670) * feat(rules): hide title conditions for bookmark created trigger * fix typecheck --- packages/trpc/lib/ruleEngine.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'packages/trpc/lib/ruleEngine.ts') diff --git a/packages/trpc/lib/ruleEngine.ts b/packages/trpc/lib/ruleEngine.ts index 6b5f8fdf..233a6acf 100644 --- a/packages/trpc/lib/ruleEngine.ts +++ b/packages/trpc/lib/ruleEngine.ts @@ -22,6 +22,7 @@ async function fetchBookmark(db: AuthedContext["db"], bookmarkId: string) { link: { columns: { url: true, + title: true, }, }, text: true, @@ -61,6 +62,16 @@ export class RuleEngine { private rules: RuleEngineRule[], ) {} + private get bookmarkTitle(): string { + return ( + this.bookmark.title ?? + (this.bookmark.type === BookmarkTypes.LINK + ? this.bookmark.link?.title + : "") ?? + "" + ); + } + static async forBookmark(ctx: AuthedContext, bookmarkId: string) { const [bookmark, rules] = await Promise.all([ fetchBookmark(ctx.db, bookmarkId), @@ -90,6 +101,12 @@ export class RuleEngine { !(this.bookmark.link?.url ?? "").includes(condition.str) ); } + case "titleContains": { + return this.bookmarkTitle.includes(condition.str); + } + case "titleDoesNotContain": { + return !this.bookmarkTitle.includes(condition.str); + } case "importedFromFeed": { return this.bookmark.rssFeeds.some( (f) => f.rssFeedId === condition.feedId, -- cgit v1.2.3-70-g09d2