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

Revert "[Regression] Omnichannel On hold Queue" #21242

Merged
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
2 changes: 1 addition & 1 deletion app/livechat/client/views/app/tabbar/visitorInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Template.visitorInfo.helpers({

canPlaceChatOnHold() {
const room = Template.instance().room.get();
return room.open && !room.onHold && room.servedBy && room.lastMessage && !room.lastMessage?.token && settings.get('Livechat_allow_manual_on_hold');
return room.open && !room.onHold && room.lastMessage && !room.lastMessage?.token && settings.get('Livechat_allow_manual_on_hold');
},

roomClosedDateTime() {
Expand Down
4 changes: 2 additions & 2 deletions app/livechat/server/lib/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export const forwardRoomToAgent = async (room, transferData) => {
const agent = { agentId, username };
// There are some Enterprise features that may interrupt the fowarding process
// Due to that we need to check whether the agent has been changed or not
const roomTaken = await RoutingManager.takeInquiry(inquiry, agent, { isForwarding: true });
const roomTaken = await RoutingManager.takeInquiry(inquiry, agent);
if (!roomTaken) {
return false;
}
Expand Down Expand Up @@ -378,7 +378,7 @@ export const forwardRoomToDepartment = async (room, guest, transferData) => {
// Fake the department to forward the inquiry - Case the forward process does not success
// the inquiry will stay in the same original department
inquiry.department = departmentId;
const roomTaken = await RoutingManager.delegateInquiry(inquiry, agent, { isForwarding: true });
const roomTaken = await RoutingManager.delegateInquiry(inquiry, agent);
if (!roomTaken) {
return false;
}
Expand Down
2 changes: 0 additions & 2 deletions app/livechat/server/lib/Livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,6 @@ export const Livechat = {
throw new Meteor.Error('error-returning-inquiry', 'Error returning inquiry to the queue', { method: 'livechat:returnRoomAsInquiry' });
}

callbacks.run('livechat:afterReturnedRoomAsInquiry', room);

return true;
},

Expand Down
10 changes: 4 additions & 6 deletions app/livechat/server/lib/RoutingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const RoutingManager = {
return this.getMethod().getNextAgent(department, ignoreAgentId);
},

async delegateInquiry(inquiry, agent = null, options = {}) {
async delegateInquiry(inquiry, agent) {
const { department, rid } = inquiry;
if (!agent || (agent.username && !Users.findOneOnlineAgentByUsername(agent.username) && !allowAgentSkipQueue(agent))) {
agent = await this.getNextAgent(department);
Expand All @@ -53,7 +53,7 @@ export const RoutingManager = {
return LivechatRooms.findOneById(rid);
}

return this.takeInquiry(inquiry, agent, options);
return this.takeInquiry(inquiry, agent);
},

assignAgent(inquiry, agent) {
Expand Down Expand Up @@ -110,7 +110,7 @@ export const RoutingManager = {
return true;
},

async takeInquiry(inquiry, agent, options = { clientAction: false, isForwarding: false }) {
async takeInquiry(inquiry, agent, options = { clientAction: false }) {
check(agent, Match.ObjectIncluding({
agentId: String,
username: String,
Expand All @@ -134,9 +134,7 @@ export const RoutingManager = {

agent = await callbacks.run('livechat.checkAgentBeforeTakeInquiry', { agent, inquiry, options });
if (!agent) {
if (!options.isForwarding) {
await callbacks.run('livechat.onAgentAssignmentFailed', { inquiry, room, options });
}
await callbacks.run('livechat.onAgentAssignmentFailed', { inquiry, room, options });
return null;
}

Expand Down
17 changes: 0 additions & 17 deletions ee/app/livechat-enterprise/server/hooks/afterForwardChatToAgent.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ callbacks.add('livechat.afterForwardChatToDepartment', (options) => {
if (!room) {
return;
}

callbacks.run('livechat:afterOnHoldChatResumed', room);

setPredictedVisitorAbandonmentTime(room);

const department = LivechatDepartment.findOneById(newDepartmentId, { fields: { ancestors: 1 } });
Expand Down
15 changes: 0 additions & 15 deletions ee/app/livechat-enterprise/server/hooks/afterOnHoldChatResumed.ts

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions ee/app/livechat-enterprise/server/hooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,3 @@ import './onCloseLivechat';
import './onSaveVisitorInfo';
import './onBusinessHourStart';
import './onAgentAssignmentFailed';
import './afterOnHoldChatResumed';
import './afterReturnedRoomAsInquiry';
import './afterForwardChatToAgent';
2 changes: 0 additions & 2 deletions ee/app/livechat-enterprise/server/hooks/onCloseLivechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { dispatchWaitingQueueStatus } from '../lib/Helper';
import { RoutingManager } from '../../../../../app/livechat/server/lib/RoutingManager';

const onCloseLivechat = (room) => {
callbacks.run('livechat:afterOnHoldChatResumed', room);

if (!settings.get('Livechat_waiting_queue')) {
return room;
}
Expand Down
10 changes: 6 additions & 4 deletions ee/app/livechat-enterprise/server/methods/resumeOnHold.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Meteor } from 'meteor/meteor';

import { LivechatRooms, LivechatInquiry } from '../../../../../app/models/server';
import { LivechatRooms, LivechatInquiry, Subscriptions } from '../../../../../app/models/server';
import { AutoCloseOnHoldScheduler } from '../lib/AutoCloseOnHoldScheduler';
import { RoutingManager } from '../../../../../app/livechat/server/lib/RoutingManager';
import { callbacks } from '../../../../../app/callbacks/server';

Meteor.methods({
async 'livechat:resumeOnHold'(roomId, options = { clientAction: false }) {
Expand All @@ -22,9 +22,11 @@ Meteor.methods({
throw new Meteor.Error('inquiry-not-found', 'Error! No inquiry found for this room', { method: 'livechat:resumeOnHold' });
}

await AutoCloseOnHoldScheduler.unscheduleRoom(roomId);

await RoutingManager.takeInquiry(inquiry, { agentId, username }, options);

const updatedRoom = LivechatRooms.findById(roomId, null);
updatedRoom && Meteor.defer(() => callbacks.run('livechat:afterOnHoldChatResumed', updatedRoom));
(LivechatRooms as any).unsetAllOnHoldFieldsByRoomId(roomId);
Subscriptions.unsetOnHold(roomId);
},
});