/** * Infrastructure Adapter: EmailNotificationAdapter (Stub) * * Handles email notifications. * Currently a stub - to be implemented when email integration is needed. */ import type { NotificationDeliveryResult, NotificationGateway } from '@core/notifications/application/ports/NotificationGateway'; import type { Notification } from '@core/notifications/domain/entities/Notification'; import type { NotificationChannel } from '@core/notifications/domain/types/NotificationTypes'; export interface EmailAdapterConfig { smtpHost?: string; smtpPort?: number; smtpUser?: string; smtpPassword?: string; fromAddress?: string; } export class EmailNotificationAdapter implements NotificationGateway { private readonly channel: NotificationChannel = 'email'; private config: EmailAdapterConfig; constructor(config: EmailAdapterConfig = {}) { this.config = config; } async send(notification: Notification): Promise { if (!this.isConfigured()) { return { success: false, channel: this.channel, error: 'Email SMTP not configured', attemptedAt: new Date(), }; } // TODO: Implement actual email sending // For now, this is a stub that logs and returns success console.log(`[Email Stub] Would send email:`, { to: notification.recipientId, // Would need to resolve to actual email subject: notification.title, body: notification.body, type: notification.type, }); return { success: true, channel: this.channel, externalId: `email-stub-${notification.id}`, attemptedAt: new Date(), }; } supportsChannel(channel: NotificationChannel): boolean { return channel === this.channel; } isConfigured(): boolean { return !!(this.config.smtpHost && this.config.fromAddress); } getChannel(): NotificationChannel { return this.channel; } /** * Update SMTP configuration */ configure(config: EmailAdapterConfig): void { this.config = { ...this.config, ...config }; } }