From a8827f36472d8019cc88ae16a5545c878ffd531c Mon Sep 17 00:00:00 2001 From: "i.navrotskyj" Date: Wed, 10 Jul 2024 18:42:45 +0300 Subject: [PATCH] WTEL-4748 --- queue/attempt.go | 16 ++++++++++++++++ queue/chat_inbound.go | 8 ++++++-- queue/queue_manager.go | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/queue/attempt.go b/queue/attempt.go index e2855a9e..50305f0e 100644 --- a/queue/attempt.go +++ b/queue/attempt.go @@ -82,6 +82,7 @@ type Attempt struct { processingFields sync.Map processingFormStarted bool bridgedAt int64 + transferredAt int64 // todo work in chat manualDistribution bool } @@ -152,6 +153,21 @@ func (a *Attempt) MarkProcessingFormStarted() { a.Unlock() } +func (a *Attempt) MarkTransferred() { + a.Lock() + if a.transferredAt == 0 { + a.transferredAt = model.GetMillis() + } + a.Unlock() +} + +func (a *Attempt) TransferredAt() int64 { + a.RLock() + t := a.transferredAt + a.RUnlock() + return t +} + func (a *Attempt) ProcessingFormStarted() bool { a.RLock() defer a.RUnlock() diff --git a/queue/chat_inbound.go b/queue/chat_inbound.go index 5fd7309c..11954da6 100644 --- a/queue/chat_inbound.go +++ b/queue/chat_inbound.go @@ -280,11 +280,15 @@ func (queue *InboundChatQueue) process(attempt *Attempt, inviterId, invUserId st // TODO: what reason is this? aSess.Close("") } - transferredProcessing := conv.Cause() == "transfer" && + transferred := conv.Cause() == "transfer" + if transferred { + attempt.MarkTransferred() + } + transferredProcessing := transferred && queue.GetVariable(transferResult) == model.MEMBER_CAUSE_ABANDONED if conv.BridgedAt() > 0 && !transferredProcessing { - team.Reporting(queue, attempt, agent, conv.ReportingAt() > 0, false) + team.Reporting(queue, attempt, agent, conv.ReportingAt() > 0, conv.Cause() == "transfer") } else { team.Missed(attempt, agent) queue.queueManager.LeavingMember(attempt) diff --git a/queue/queue_manager.go b/queue/queue_manager.go index 5c332b3b..44b4fc6e 100644 --- a/queue/queue_manager.go +++ b/queue/queue_manager.go @@ -961,7 +961,7 @@ func (queueManager *QueueManager) closeBeforeReporting(attemptId int64, res *mod break case model.QueueChannelChat: var conv *chat.Conversation - if a != nil { + if a != nil && a.TransferredAt() == 0 { if conv, err = queueManager.GetChat(a.memberChannel.Id()); err == nil { err = conv.Reporting(false) }