Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVE] Ignore agent status when queuing incoming livechats via Guest Pool #13818

Merged
merged 5 commits into from
Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion app/livechat/server/api/lib/livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { Random } from 'meteor/random';
import { Users, Rooms, LivechatVisitors, LivechatDepartment, LivechatTrigger } from '../../../../models';
import _ from 'underscore';
import { Livechat } from '../../lib/Livechat';
import { settings as rcSettings } from '../../../../settings';

export function online() {
return Users.findOnlineAgents().count() > 0;
const onlineAgents = Livechat.getOnlineAgents();
return (onlineAgents && onlineAgents.count() > 0) || rcSettings.get('Livechat_guest_pool_with_no_agents');
}

export function findTriggers() {
Expand Down
7 changes: 1 addition & 6 deletions app/livechat/server/lib/Livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,12 +533,7 @@ export const Livechat = {
const agentIds = [];
// get the agents of the department
if (departmentId) {
let agents = Livechat.getOnlineAgents(departmentId);

if (agents.count() === 0 && settings.get('Livechat_guest_pool_with_no_agents')) {
agents = Livechat.getAgents(departmentId);
}

const agents = Livechat.getAgents(departmentId);
renatobecker-zz marked this conversation as resolved.
Show resolved Hide resolved
if (agents.count() === 0) {
return false;
}
Expand Down
12 changes: 7 additions & 5 deletions app/livechat/server/lib/QueueMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ export const QueueMethods = {
* only the client until paired with an agent
*/
'Guest_Pool'(guest, message, roomInfo) {
let agents = Livechat.getOnlineAgents(guest.department);

if (agents.count() === 0 && settings.get('Livechat_guest_pool_with_no_agents')) {
agents = Livechat.getAgents(guest.department);
if (settings.get('Livechat_guest_pool_with_no_agents') === false) {
const onlineAgents = Livechat.getOnlineAgents(guest.department);
if (!onlineAgents || onlineAgents.count() === 0) {
throw new Meteor.Error('no-agent-online', 'Sorry, no online agents');
}
}

const agents = Livechat.getAgents(guest.department);
if (agents.count() === 0) {
throw new Meteor.Error('no-agent-online', 'Sorry, no online agents');
throw new Meteor.Error('no-agent-available', 'Sorry, no available agents.');
}

Rooms.updateLivechatRoomCount();
Expand Down