Implements a three-phase Sieve email filtering pipeline: - Data models (SieveCondition, SieveAction, SieveRule) as sealed Dart classes - SieveParser: converts RFC 5228 Sieve scripts to a flat SieveRule list, supporting if/elsif/else, allof/anyof, header/size/exists tests, and all common actions (fileinto, keep, discard, flag, mark) - SieveInterpreter: evaluates compiled rules against a SieveEmailContext, tracking routing state in SieveExecutionContext with implicit keep behaviour - 40 unit tests covering parser correctness and interpreter execution Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
22 lines
607 B
Dart
22 lines
607 B
Dart
import 'package:sharedinbox/core/sieve/sieve_actions.dart';
|
|
import 'package:sharedinbox/core/sieve/sieve_conditions.dart';
|
|
|
|
class SieveRule {
|
|
const SieveRule({
|
|
required this.joinType,
|
|
required this.conditions,
|
|
required this.actions,
|
|
this.branchGroupId,
|
|
this.isElseBranch = false,
|
|
});
|
|
|
|
// 'allof', 'anyof', or 'single'
|
|
final String joinType;
|
|
final List<SieveCondition> conditions;
|
|
final List<SieveAction> actions;
|
|
// Non-null groups this rule into an if/elsif/else chain.
|
|
final int? branchGroupId;
|
|
// True for the unconditional else branch.
|
|
final bool isElseBranch;
|
|
}
|