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,4 +1,7 @@
|
||||
import * as plugins from '../../plugins.ts';
|
||||
import { EventEmitter } from 'node:events';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { logger } from '../../logger.ts';
|
||||
import { type EmailProcessingMode } from '../routing/classes.email.config.ts';
|
||||
import type { IEmailRoute } from '../routing/interfaces.ts';
|
||||
@@ -71,7 +74,7 @@ export interface IQueueStats {
|
||||
/**
|
||||
* A unified queue for all email modes
|
||||
*/
|
||||
export class UnifiedDeliveryQueue extends plugins.EventEmitter {
|
||||
export class UnifiedDeliveryQueue extends EventEmitter {
|
||||
private options: Required<IQueueOptions>;
|
||||
private queue: Map<string, IQueueItem> = new Map();
|
||||
private checkTimer?: NodeJS.Timeout;
|
||||
@@ -423,7 +426,7 @@ export class UnifiedDeliveryQueue extends plugins.EventEmitter {
|
||||
*/
|
||||
private async persistItem(item: IQueueItem): Promise<void> {
|
||||
try {
|
||||
const filePath = path.join(this.options.persistentPath, `${item.id}.tson`);
|
||||
const filePath = path.join(this.options.persistentPath, `${item.id}.json`);
|
||||
await fs.promises.writeFile(filePath, JSON.stringify(item, null, 2), 'utf8');
|
||||
} catch (error) {
|
||||
logger.log('error', `Failed to persist item ${item.id}: ${error.message}`);
|
||||
@@ -437,7 +440,7 @@ export class UnifiedDeliveryQueue extends plugins.EventEmitter {
|
||||
*/
|
||||
private async removeItemFromDisk(id: string): Promise<void> {
|
||||
try {
|
||||
const filePath = path.join(this.options.persistentPath, `${id}.tson`);
|
||||
const filePath = path.join(this.options.persistentPath, `${id}.json`);
|
||||
|
||||
if (fs.existsSync(filePath)) {
|
||||
await fs.promises.unlink(filePath);
|
||||
@@ -459,7 +462,7 @@ export class UnifiedDeliveryQueue extends plugins.EventEmitter {
|
||||
}
|
||||
|
||||
// Get all JSON files
|
||||
const files = fs.readdirSync(this.options.persistentPath).filter(file => file.endsWith('.tson'));
|
||||
const files = fs.readdirSync(this.options.persistentPath).filter(file => file.endsWith('.json'));
|
||||
|
||||
// Load each file
|
||||
for (const file of files) {
|
||||
|
||||
Reference in New Issue
Block a user