From 6c60706653b6be18537e41bd2713be0583c590b5 Mon Sep 17 00:00:00 2001 From: "i.navrotskyj" Date: Fri, 26 Apr 2024 10:58:05 +0300 Subject: [PATCH] DEV-3338 --- call_manager/call.go | 12 ++++++++++++ queue/call.go | 7 ++++++- queue/call_predict.go | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/call_manager/call.go b/call_manager/call.go index 5701bb9f..68e03885 100644 --- a/call_manager/call.go +++ b/call_manager/call.go @@ -53,6 +53,7 @@ type Call interface { WaitSeconds() int AmdResult() string + HasAmdError() bool IsHuman() bool WaitForHangup() @@ -533,6 +534,17 @@ func (call *CallImpl) IsHuman() bool { return call.amdResult == AmdHuman || call.amdResult == AmdNotSure } +func (call *CallImpl) HasAmdError() bool { + call.RLock() + f := call.amdAiResult + call.RUnlock() + if f.Error != "" || f.Result == "undefined" { + return true + } + + return false +} + func (call *CallImpl) DurationSeconds() int { if call.hangupAt > 0 { return int(call.hangupAt-call.ringingAt) / 1000 diff --git a/queue/call.go b/queue/call.go index 3c8b7fd6..eb461725 100644 --- a/queue/call.go +++ b/queue/call.go @@ -263,11 +263,16 @@ func IsHuman(call call_manager.Call, amd *model.QueueAmdSettings) bool { if amd.Ai { aiAmd := call.AiResult() + answered := call.Answered() if aiAmd.Error != "" || aiAmd.Result == "undefined" { - return true // TODO ? + return answered // TODO ? DEV-3338 } for _, v := range amd.PositiveTags { if v == aiAmd.Result { + if !answered && call.HangupAt() == 0 { // TODO ? DEV-3338 + call.Hangup(model.CALL_HANGUP_NORMAL_UNSPECIFIED, false, nil) + return false + } return true } } diff --git a/queue/call_predict.go b/queue/call_predict.go index 0d301b7d..f600d443 100644 --- a/queue/call_predict.go +++ b/queue/call_predict.go @@ -226,7 +226,7 @@ retry_: switch state { case call_manager.CALL_STATE_ACCEPT, call_manager.CALL_STATE_DETECT_AMD: // FIXME - if (state == call_manager.CALL_STATE_ACCEPT && queue.Amd != nil && queue.Amd.Enabled) || (state == call_manager.CALL_STATE_DETECT_AMD && !IsHuman(mCall, queue.Amd)) { + if (state == call_manager.CALL_STATE_ACCEPT && !mCall.HasAmdError() && queue.Amd != nil && queue.Amd.Enabled) || (state == call_manager.CALL_STATE_DETECT_AMD && !IsHuman(mCall, queue.Amd)) { continue }