export interface SendNotificationInput {
  channel: 'email' | 'slack' | 'webhook' | 'dingtalk' | 'wecom';
  recipients: string[];
  subject?: string;
  message: string;
  templateId?: string;
}

export interface SendNotificationOutput {
  sent: boolean;
  messageId: string;
}

/**
 * Send a notification via the configured channel.
 * Currently stubs — implement actual integrations as needed.
 */
export async function sendNotification(input: SendNotificationInput): Promise<SendNotificationOutput> {
  const { channel, recipients, subject, message } = input;

  console.log(`[Notification] channel=${channel} recipients=${recipients.join(',')} subject=${subject || ''}`);
  console.log(`[Notification] message: ${message}`);

  // TODO: Implement actual notification channels
  // For now, log and return success
  switch (channel) {
    case 'webhook': {
      // For webhook channel, POST to each recipient URL
      const axios = (await import('axios')).default;
      for (const url of recipients) {
        await axios.post(url, { subject, message });
      }
      break;
    }
    case 'email':
    case 'slack':
    case 'dingtalk':
    case 'wecom':
      // Stub: log only
      break;
  }

  return {
    sent: true,
    messageId: `notif_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
  };
}
