Skip to content

Commit

Permalink
DEV-3338
Browse files Browse the repository at this point in the history
  • Loading branch information
i.navrotskyj committed Apr 26, 2024
1 parent 4485596 commit 6c60706
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
12 changes: 12 additions & 0 deletions call_manager/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type Call interface {
WaitSeconds() int

AmdResult() string
HasAmdError() bool
IsHuman() bool

WaitForHangup()
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion queue/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion queue/call_predict.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 6c60706

Please sign in to comment.