feat(storage): add comprehensive tests for StorageManager with memory, filesystem, and custom function backends
feat(email): implement EmailSendJob class for robust email delivery with retry logic and MX record resolution feat(mail): restructure mail module exports for simplified access to core and delivery functionalities
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import * as plugins from '../../plugins.ts';
|
||||
import type { IEmailDomainConfig } from './interfaces.ts';
|
||||
import { logger } from '../../logger.ts';
|
||||
import type { DcRouter } from '../../classes.mailer.ts';
|
||||
import type { DcRouter } from '../../classes.dcrouter.ts';
|
||||
import type { StorageManager } from '../../storage/index.ts';
|
||||
|
||||
/**
|
||||
|
||||
@@ -416,7 +416,7 @@ export class DNSManager {
|
||||
*/
|
||||
public async saveDnsRecommendations(domain: string, records: IDnsRecord[]): Promise<void> {
|
||||
try {
|
||||
const filePath = plugins.path.join(paths.dnsRecordsDir, `${domain}.recommendations.tson`);
|
||||
const filePath = plugins.path.join(paths.dnsRecordsDir, `${domain}.recommendations.json`);
|
||||
plugins.smartfile.memory.toFsSync(JSON.stringify(records, null, 2), filePath);
|
||||
console.log(`DNS recommendations for ${domain} saved to ${filePath}`);
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import * as plugins from '../../plugins.ts';
|
||||
import { EventEmitter } from 'node:events';
|
||||
import type { IEmailRoute, IEmailMatch, IEmailAction, IEmailContext } from './interfaces.ts';
|
||||
import type { Email } from '../core/classes.email.ts';
|
||||
|
||||
/**
|
||||
* Email router that evaluates routes and determines actions
|
||||
*/
|
||||
export class EmailRouter extends plugins.EventEmitter {
|
||||
export class EmailRouter extends EventEmitter {
|
||||
private routes: IEmailRoute[];
|
||||
private patternCache: Map<string, boolean> = new Map();
|
||||
private storageManager?: any; // StorageManager instance
|
||||
@@ -407,7 +408,7 @@ export class EmailRouter extends plugins.EventEmitter {
|
||||
}
|
||||
|
||||
const routesData = JSON.stringify(this.routes, null, 2);
|
||||
await this.storageManager.set('/email/routes/config.tson', routesData);
|
||||
await this.storageManager.set('/email/routes/config.json', routesData);
|
||||
|
||||
this.emit('routesPersisted', this.routes.length);
|
||||
} catch (error) {
|
||||
@@ -430,7 +431,7 @@ export class EmailRouter extends plugins.EventEmitter {
|
||||
}
|
||||
|
||||
try {
|
||||
const routesData = await this.storageManager.get('/email/routes/config.tson');
|
||||
const routesData = await this.storageManager.get('/email/routes/config.json');
|
||||
|
||||
if (!routesData) {
|
||||
return [];
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as plugins from '../../plugins.ts';
|
||||
import * as paths from '../../paths.ts';
|
||||
import { EventEmitter } from 'events';
|
||||
import { logger } from '../../logger.ts';
|
||||
import {
|
||||
SecurityLogger,
|
||||
@@ -28,7 +29,7 @@ import { UnifiedDeliveryQueue, type IQueueOptions } from '../delivery/classes.de
|
||||
import { UnifiedRateLimiter, type IHierarchicalRateLimits } from '../delivery/classes.unified.rate.limiter.ts';
|
||||
import { SmtpState } from '../delivery/interfaces.ts';
|
||||
import type { EmailProcessingMode, ISmtpSession as IBaseSmtpSession } from '../delivery/interfaces.ts';
|
||||
import type { DcRouter } from '../../classes.mailer.ts';
|
||||
import type { DcRouter } from '../../classes.dcrouter.ts';
|
||||
|
||||
/**
|
||||
* Extended SMTP session interface with route information
|
||||
@@ -153,7 +154,7 @@ export interface IServerStats {
|
||||
/**
|
||||
* Unified email server that handles all email traffic with pattern-based routing
|
||||
*/
|
||||
export class UnifiedEmailServer extends plugins.EventEmitter {
|
||||
export class UnifiedEmailServer extends EventEmitter {
|
||||
private dcRouter: DcRouter;
|
||||
private options: IUnifiedEmailServerOptions;
|
||||
private emailRouter: EmailRouter;
|
||||
|
||||
Reference in New Issue
Block a user