Skip to content

Commit

Permalink
[FIX] Checks the list of agents if at least one is online (#22584)
Browse files Browse the repository at this point in the history
Co-authored-by: Diego Sampaio <[email protected]>
  • Loading branch information
tiagoevanp and sampaiodiego committed Jul 7, 2021
1 parent 8de118a commit af73448
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/livechat/server/lib/QueueManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const QueueManager = {
};

let defaultAgent;
if (servedBy && Users.findOneOnlineAgentByUsername(servedBy.username)) {
if (servedBy && Users.findOneOnlineAgentByUserList(servedBy.username)) {
defaultAgent = { agentId: servedBy._id, username: servedBy.username };
}

Expand Down
2 changes: 1 addition & 1 deletion app/livechat/server/lib/RoutingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const RoutingManager = {

async delegateInquiry(inquiry, agent, options = {}) {
const { department, rid } = inquiry;
if (!agent || (agent.username && !Users.findOneOnlineAgentByUsername(agent.username) && !allowAgentSkipQueue(agent))) {
if (!agent || (agent.username && !Users.findOneOnlineAgentByUserList(agent.username) && !allowAgentSkipQueue(agent))) {
agent = await this.getNextAgent(department);
}

Expand Down
2 changes: 1 addition & 1 deletion app/livechat/server/lib/routing/External.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ExternalQueue {
});

if (result && result.data && result.data.username) {
const agent = Users.findOneOnlineAgentByUsername(result.data.username);
const agent = Users.findOneOnlineAgentByUserList(result.data.username);

if (agent) {
return {
Expand Down
2 changes: 1 addition & 1 deletion app/models/server/models/LivechatDepartmentAgents.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class LivechatDepartmentAgents extends Base {
return false;
}

const onlineUser = Users.findOneOnlineAgentByUsername(_.pluck(agents, 'username'));
const onlineUser = Users.findOneOnlineAgentByUserList(_.pluck(agents, 'username'));

return Boolean(onlineUser);
}
Expand Down
6 changes: 5 additions & 1 deletion app/models/server/models/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ export class Users extends Base {
return this.findOne(query);
}

findOneOnlineAgentByUsername(username, options) { // TODO:: Create class Agent
findOneOnlineAgentByUserList(userList, options) { // TODO:: Create class Agent
const username = {
$in: [].concat(userList),
};

const query = queryStatusAgentOnline({ username });

return this.findOne(query, options);
Expand Down

0 comments on commit af73448

Please sign in to comment.