/**
 * Slack notification helper.
 * Sends a simple text message to a Slack incoming webhook URL.
 */

export async function sendSlackNotification(
  webhookUrl: string,
  message: string,
  _channel?: string,
): Promise<void> {
  const body: Record<string, string> = { text: message };

  const controller = new AbortController();
  const timeout = setTimeout(() => controller.abort(), 5_000);

  try {
    await fetch(webhookUrl, {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify(body),
      signal: controller.signal,
    });
  } finally {
    clearTimeout(timeout);
  }
}
