Files
Edu/services/msg/src/channels/email.channel.ts
SpecialX 7b7abbb309 feat(msg): 完整实现 msg 消息服务
包含 channels/preferences/templates/grpc/kafka/outbox/push/redis 等完整实现
2026-07-10 19:09:52 +08:00

34 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { logger } from "../shared/observability/logger.js";
import type {
ChannelSendContext,
ChannelSendResult,
NotificationChannelStrategy,
} from "./channel.types.js";
/**
* EmailChannel —— 邮件渠道P5 stub
*
* P5 阶段无实际 SMTP 网关,仅记录投递意图。
* 后续接入 SMTP 服务时替换 send 实现,接口不变(策略模式扩展点)。
*
* 仲裁依据 02-architecture-design.md §2.4:软失败,不阻断主流程。
*/
class EmailChannel implements NotificationChannelStrategy {
readonly name = "email" as const;
async send(ctx: ChannelSendContext): Promise<ChannelSendResult> {
// P5 stub记录投递意图不实际发送
logger.info(
{ userId: ctx.userId, notificationId: ctx.notificationId },
"Email channel stub: delivery intent logged (SMTP not configured)",
);
return {
channel: "email",
sent: false,
error: "SMTP gateway not configured (P5 stub)",
};
}
}
export const emailChannel = new EmailChannel();