Skip to content

Commit

Permalink
WTEL-4153
Browse files Browse the repository at this point in the history
  • Loading branch information
navrotskyj committed Jan 18, 2024
1 parent 43926f6 commit ee77da4
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
8 changes: 8 additions & 0 deletions call_manager/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Call interface {
AddAction(action CallAction)

BridgeId() *string
Answered() bool

AcceptAt() int64
BridgeAt() int64
Expand Down Expand Up @@ -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
}
Expand Down
7 changes: 7 additions & 0 deletions chat/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion queue/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
type Channel interface {
Id() string
Stats() map[string]string
Answered() bool
}

type ChannelEvent struct {
Expand All @@ -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"`
Expand Down
7 changes: 7 additions & 0 deletions queue/queue_agent_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
13 changes: 13 additions & 0 deletions queue/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit ee77da4

Please sign in to comment.