261006_02_ENH: 발신번호 미등록 시 전화걸기 차단 및 CTI 발신 오류(MakeCallError) 처리

This commit is contained in:
2026-10-06 14:33:01 +09:00
parent 746f709e92
commit cf208b7f38
3 changed files with 40 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import { HttpError } from "@kri/common/http";
import {
CTI_AGENT_GROUP,
CTI_DIALING_TIMEOUT_MS,
CTI_ERROR_ALERT_THROTTLE_MS,
CTI_ON_CALL_STATUSES,
CTI_STATE_TTL_MS,
} from "@/const/ctiConst";
@@ -96,6 +97,7 @@ let hangupRequested = false;
let callClosedReceived = false;
let reconnectIntervalId: ReturnType<typeof setInterval> | null = null;
let dialingTimeoutId: ReturnType<typeof setTimeout> | null = null;
const lastErrorAlertAt = new Map<string, number>();
const listeners = new Set<() => void>();
@@ -506,6 +508,16 @@ const saveCallHistory = (parsed: Record<string, unknown>, phase: "start" | "clos
};
// 외주 문서에 오류 명세가 없어, 처리하지 않는 오류는 상태를 건드리지 않고 알리기만 한다.
// 재연결 루프 등으로 같은 오류가 반복될 수 있어 ZCommand별로 일정 간격 안의 중복 alert는 생략한다.
const alertUnhandledError = (zCommand: string) => {
const now = Date.now();
const lastAt = lastErrorAlertAt.get(zCommand);
if (lastAt !== undefined && now - lastAt < CTI_ERROR_ALERT_THROTTLE_MS) return;
lastErrorAlertAt.set(zCommand, now);
alert(`${zCommand} 오류가 발생했습니다. 관리자에게 문의하세요.`);
};
// WS 서버 -> 클라이언트로 오는 메시지는 ZCommand가 기준값이다.
// 새로운 서버 이벤트에 대한 후속 조치가 필요하면 여기 case를 추가한다.
const handleIncomingMessage = (raw: unknown) => {
@@ -575,7 +587,23 @@ const handleIncomingMessage = (raw: unknown) => {
}
break;
}
case "MakeCallError": {
console.warn("[CTI][TEMP_LOG] MakeCallError ->", parsed); // TEMP_CTI_LOG
// 오류 메시지에는 AgntSessionID가 없어 어떤 발신인지 대조할 수 없으므로, 받기 전(dialing) 상태일 때만 정리한다.
if (activeCall && activeCall.agentSessionId == null) {
clearDialingTimeout();
activeCall = null;
persistCtiState();
notify();
}
alert("전화 연결에 실패했습니다.");
break;
}
default:
console.warn("[CTI][TEMP_LOG] unhandled message ->", parsed.ZCommand, parsed); // TEMP_CTI_LOG
if (typeof parsed.ZCommand === "string" && parsed.ZCommand.includes("Error")) {
alertUnhandledError(parsed.ZCommand);
}
break;
}
};