import { logger } from "../shared/observability/logger.js";
import type {
  ChannelSendContext,
  ChannelSendResult,
  NotificationChannelStrategy,
} from "./channel.types.js";

/**
 * SmsChannel —— 短信渠道（P5 stub）。
 *
 * P5 阶段无实际 SMS 网关，仅记录投递意图。
 * 后续接入短信服务商时替换 send 实现，接口不变（策略模式扩展点）。
 *
 * 仲裁依据 02-architecture-design.md §2.4：软失败，不阻断主流程。
 */
class SmsChannel implements NotificationChannelStrategy {
  readonly name = "sms" as const;

  async send(ctx: ChannelSendContext): Promise<ChannelSendResult> {
    // P5 stub：记录投递意图，不实际发送
    logger.info(
      { userId: ctx.userId, notificationId: ctx.notificationId },
      "SMS channel stub: delivery intent logged (gateway not configured)",
    );
    return {
      channel: "sms",
      sent: false,
      error: "SMS gateway not configured (P5 stub)",
    };
  }
}

export const smsChannel = new SmsChannel();
