feat: implement comprehensive route-based email routing system
Replace legacy domain-rule based routing with flexible route-based system that supports: - Multi-criteria matching (recipients, senders, IPs, authentication) - Four action types (forward, process, deliver, reject) - Moved DKIM signing to delivery phase for signature validity - Connection pooling for efficient email forwarding - Pattern caching for improved performance This provides more granular control over email routing with priority-based matching and comprehensive test coverage.
This commit is contained in:
@ -3,7 +3,8 @@ import { EventEmitter } from 'node:events';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { logger } from '../../logger.js';
|
||||
import { type EmailProcessingMode, type IDomainRule } from '../routing/classes.email.config.js';
|
||||
import { type EmailProcessingMode } from '../routing/classes.email.config.js';
|
||||
import type { IEmailRoute } from '../routing/interfaces.js';
|
||||
|
||||
/**
|
||||
* Queue item status
|
||||
@ -17,7 +18,7 @@ export interface IQueueItem {
|
||||
id: string;
|
||||
processingMode: EmailProcessingMode;
|
||||
processingResult: any;
|
||||
rule: IDomainRule;
|
||||
route: IEmailRoute;
|
||||
status: QueueItemStatus;
|
||||
attempts: number;
|
||||
nextAttempt: Date;
|
||||
@ -218,9 +219,9 @@ export class UnifiedDeliveryQueue extends EventEmitter {
|
||||
* Add an item to the queue
|
||||
* @param processingResult Processing result to queue
|
||||
* @param mode Processing mode
|
||||
* @param rule Domain rule
|
||||
* @param route Email route
|
||||
*/
|
||||
public async enqueue(processingResult: any, mode: EmailProcessingMode, rule: IDomainRule): Promise<string> {
|
||||
public async enqueue(processingResult: any, mode: EmailProcessingMode, route: IEmailRoute): Promise<string> {
|
||||
// Check if queue is full
|
||||
if (this.queue.size >= this.options.maxQueueSize) {
|
||||
throw new Error('Queue is full');
|
||||
@ -234,7 +235,7 @@ export class UnifiedDeliveryQueue extends EventEmitter {
|
||||
id,
|
||||
processingMode: mode,
|
||||
processingResult,
|
||||
rule,
|
||||
route,
|
||||
status: 'pending',
|
||||
attempts: 0,
|
||||
nextAttempt: new Date(),
|
||||
|
Reference in New Issue
Block a user