From ee77da40f9703f5b8cb60593597a343bc95caf5e Mon Sep 17 00:00:00 2001 From: Igor Navrotskyj Date: Thu, 18 Jan 2024 13:01:50 +0200 Subject: [PATCH] WTEL-4153 --- call_manager/call.go | 8 ++++++++ chat/session.go | 7 +++++++ queue/events.go | 3 ++- queue/queue_agent_task.go | 7 +++++++ queue/schema.go | 13 +++++++++++++ 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/call_manager/call.go b/call_manager/call.go index da17f281..aae8faad 100644 --- a/call_manager/call.go +++ b/call_manager/call.go @@ -33,6 +33,7 @@ type Call interface { AddAction(action CallAction) BridgeId() *string + Answered() bool AcceptAt() int64 BridgeAt() int64 @@ -510,6 +511,13 @@ func (call *CallImpl) AcceptAt() int64 { return call.acceptAt } +func (call *CallImpl) Answered() bool { + call.RLock() + a := call.acceptAt + call.RUnlock() + return a > 0 +} + func (call *CallImpl) BridgeAt() int64 { return call.bridgeAt } diff --git a/chat/session.go b/chat/session.go index ec3b6328..a5efa5c3 100644 --- a/chat/session.go +++ b/chat/session.go @@ -67,6 +67,13 @@ func (c *ChatSession) SessionId() string { return c.InviteId } +func (c *ChatSession) Answered() bool { + c.RLock() + a := c.AnsweredAt + c.RUnlock() + + return a > 0 +} func (c *ChatSession) SetActivity() { c.Lock() diff --git a/queue/events.go b/queue/events.go index 878a5c28..3f59560d 100644 --- a/queue/events.go +++ b/queue/events.go @@ -10,6 +10,7 @@ import ( type Channel interface { Id() string Stats() map[string]string + Answered() bool } type ChannelEvent struct { @@ -19,7 +20,7 @@ type ChannelEvent struct { Timestamp int64 `json:"timestamp"` } -//TODO refactoring call event to CC +// TODO refactoring call event to CC type Distribute struct { AppId string `json:"app_id"` Channel string `json:"channel"` diff --git a/queue/queue_agent_task.go b/queue/queue_agent_task.go index 0a8c98d6..2527113e 100644 --- a/queue/queue_agent_task.go +++ b/queue/queue_agent_task.go @@ -68,6 +68,13 @@ func (t *TaskChannel) setState(state TaskState) { t.stateC <- t.state } +func (t *TaskChannel) Answered() bool { + t.RLock() + a := t.bridgedAt + t.RUnlock() + return a > 0 +} + func (t *TaskChannel) SetAnswered() *model.AppError { t.Lock() defer t.Unlock() diff --git a/queue/schema.go b/queue/schema.go index 3e39939b..f1e0a26e 100644 --- a/queue/schema.go +++ b/queue/schema.go @@ -176,6 +176,19 @@ func (qm *QueueManager) AfterDistributeSchema(att *Attempt) (*model.SchemaResult st := time.Now() + // TODO WTEL-4153 + if att.Result() == "" && att.memberChannel != nil { + if att.agentChannel != nil && att.agentChannel.Answered() && att.memberChannel.Answered() { + vars["cc_result"] = "success" + } else { + vars["cc_result"] = "abandoned" + } + + if !att.memberChannel.Answered() { + vars["cc_result"] = "failed" + } + } + res, err := qm.app.FlowManager().Queue().ResultAttempt(&flow.ResultAttemptRequest{ DomainId: att.queue.DomainId(), SchemaId: *att.queue.AfterSchemaId(),