diff --git a/apps/web/utils/ai/choose-rule/match-rules.ts b/apps/web/utils/ai/choose-rule/match-rules.ts index 8afb2d5f00..9168ce1a9d 100644 --- a/apps/web/utils/ai/choose-rule/match-rules.ts +++ b/apps/web/utils/ai/choose-rule/match-rules.ts @@ -2,6 +2,7 @@ import { getConditionTypes, isAIRule } from "@/utils/condition"; import { findMatchingGroup, getGroupsWithRules, + type GroupsWithRules, } from "@/utils/group/find-matching-group"; import type { ParsedMessage, RuleWithActions } from "@/utils/types"; import { @@ -296,7 +297,7 @@ export function evaluateRuleConditions({ // Lazy load learned patterns when needed class LearnedPatternsLoader { - private groups?: Awaited> | null; + private groups?: GroupsWithRules | null; async getGroups(emailAccountId: string) { if (this.groups === undefined) @@ -496,7 +497,7 @@ export function splitEmailPatterns(pattern: string): string[] { function matchesGroupRule( rule: RuleWithActions, - groups: Awaited>, + groups: GroupsWithRules, message: ParsedMessage, ) { const ruleGroup = groups.find((g) => g.rule?.id === rule.id); diff --git a/apps/web/utils/group/find-matching-group.ts b/apps/web/utils/group/find-matching-group.ts index c9a6335e05..853f75d1c7 100644 --- a/apps/web/utils/group/find-matching-group.ts +++ b/apps/web/utils/group/find-matching-group.ts @@ -3,15 +3,20 @@ import { generalizeSubject } from "@/utils/string"; import type { ParsedMessage } from "@/utils/types"; import { type GroupItem, GroupItemType } from "@prisma/client"; -type GroupsWithRules = Awaited>; +export type GroupsWithRules = Awaited>; export async function getGroupsWithRules({ emailAccountId, + enabledOnly = true, }: { emailAccountId: string; + enabledOnly?: boolean; }) { return prisma.group.findMany({ - where: { emailAccountId, rule: { isNot: null } }, + where: { + emailAccountId, + rule: enabledOnly ? { enabled: true } : { isNot: null }, + }, include: { items: true, rule: { include: { actions: true } } }, }); } diff --git a/version.txt b/version.txt index b4df795365..0706964d7a 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v2.17.8 +v2.17.9