diff options
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, |
