diff options
| author | Andrii Mokhovyk <andrii.mokhovyk@gmail.com> | 2026-01-18 16:36:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-18 14:36:49 +0000 |
| commit | c56cf4e24f6134547fb9c5b58eb20840f5083e9e (patch) | |
| tree | ec9792cfcc6cbc6e45490d02e140b9241dca3fae /packages/trpc/lib/ruleEngine.ts | |
| parent | 1b98014d6cb0e3eb824d58ccbd35f39864e6ec88 (diff) | |
| download | karakeep-c56cf4e24f6134547fb9c5b58eb20840f5083e9e.tar.zst | |
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
Diffstat (limited to 'packages/trpc/lib/ruleEngine.ts')
| -rw-r--r-- | packages/trpc/lib/ruleEngine.ts | 17 |
1 files changed, 17 insertions, 0 deletions
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, |
