Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion controller/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
)

func (c *Controller) GetAgentSession(ctx context.Context, session *auth_manager.Session, domainId, userId int64) (*model.AgentSession, model.AppError) {

v, err := c.app.AgentCC(ctx, session.Domain(domainId), userId)
if err != nil {
return nil, err
Expand Down
5 changes: 3 additions & 2 deletions model/cc_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ type AgentSession struct {
Status string `json:"status" db:"status"`
StatusPayload *string `json:"status_payload" db:"status_payload"`
StatusComment *string `json:"status_comment" db:"status_comment"`
OnlineStatus *Lookup `json:"online_status" db:"online_status"`
LastStatusChange int64 `json:"last_status_change" db:"last_status_change"`
StatusDuration int64 `json:"status_duration" db:"status_duration"`
OnDemand bool `json:"on_demand" db:"on_demand"`
Expand Down Expand Up @@ -282,8 +283,8 @@ func (a *AgentCC) Valid() AppError {
return nil
}

func (a AgentSession) ToMap() map[string]interface{} {
out := make(map[string]interface{})
func (a AgentSession) ToMap() map[string]any {
out := make(map[string]any)
data, _ := json.Marshal(a)
_ = json.Unmarshal(data, &out)
return out
Expand Down
4 changes: 3 additions & 1 deletion store/sqlstore/cc_agent_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,8 @@ func (s SqlAgentStore) GetSession(ctx context.Context, domainId, userId int64) (
FROM directory.wbt_user aud
WHERE aud.id = any(a.auditor_ids)) auditor,
a.screen_control,
exists(select 1 from call_center.socket_session_view ss where ss.user_id = a.user_id and ss.pong < 65 and application_name = 'desc_track') as desc_track
exists(select 1 from call_center.socket_session_view ss where ss.user_id = a.user_id and ss.pong < 65 and application_name = 'desc_track') as desc_track,
call_center.cc_get_lookup(os.id, os.name) as online_status
from call_center.cc_agent a
left join call_center.cc_team t on t.id = a.team_id
LEFT JOIN LATERAL ( SELECT jsonb_agg(json_build_object('channel', c.channel, 'state', c.state, 'open', 0, 'max_open', c.max_opened,
Expand All @@ -724,6 +725,7 @@ from call_center.cc_agent a
'timeout', call_center.cc_view_timestamp(c.timeout))) AS x
FROM call_center.cc_agent_channel c
WHERE c.agent_id = a.id) ch ON true
left join call_center.cc_online_skills os on os.id = a.status_id
where a.user_id = :UserId and a.domain_id = :DomainId`, map[string]any{
"UserId": userId,
"DomainId": domainId,
Expand Down
17 changes: 8 additions & 9 deletions wsapi/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,18 @@ func (api *API) subscribeAgentsStatus(ctx context.Context, conn *app.WebConn, re
return nil, h.SubscribeSessionAgentStatus(conn, int(agentId))
}

func (api *API) getAgentSession(ctx context.Context, conn *app.WebConn, req *model.WebSocketRequest) (map[string]interface{}, model.AppError) {
var userId int64
var domainId int64
var ok bool
if userId, ok = req.Data["user_id"].(int64); !ok {
userId = conn.UserId
func (api *API) getAgentSession(ctx context.Context, conn *app.WebConn, req *model.WebSocketRequest) (map[string]any, model.AppError) {
userID, ok := req.Get("user_id").(int64)
if !ok {
userID = conn.UserId
}

if domainId, ok = req.Data["domain_id"].(int64); !ok {
domainId = conn.DomainId
domainID, ok := req.Get("domain_id").(int64)
if !ok {
domainID = conn.DomainId
}

sess, err := api.ctrl.GetAgentSession(ctx, conn.GetSession(), domainId, userId)
sess, err := api.ctrl.GetAgentSession(ctx, conn.GetSession(), domainID, userID)
if err != nil {
return nil, err
}
Expand Down
Loading