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

[FIX] Send Livechat back to Guest Pool #10731

Merged
merged 8 commits into from
Jul 21, 2018

Conversation

renatobecker-zz
Copy link

@renatobecker-zz renatobecker-zz commented May 10, 2018

Closes #7397
Closes #9278
Closes #11347

This PR fixes the forward chat in Livechat rooms when using the Guest Pool routing method. Until then, when a chat was redirected to a department, for example, it was being assigned to an agent randomly instead of returning to the pool.
In addition, it also fixes the #9278, having the same behaviour when an agent goes offline and the Livechat_agent_leave_action setting is set to forward.

@renatobecker-zz renatobecker-zz added this to the 0.65.0 milestone May 10, 2018
@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-10731 May 10, 2018 14:36 Inactive
@@ -307,7 +307,7 @@ RocketChat.Livechat = {

forwardOpenChats(userId) {
RocketChat.models.Rooms.findOpenByAgent(userId).forEach((room) => {
const guest = RocketChat.models.Users.findOneById(room.v._id);
const guest = LivechatVisitors.findOneById(room.v._id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh... this is an important fix.

Copy link
Member

@sampaiodiego sampaiodiego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not closes #9278 .. the change requested was to add an option to the following setting:
image

also, why transfering a chat should send it back to the pool? there is a button specially for this..

@sampaiodiego sampaiodiego modified the milestones: 0.65.0, 0.66.0 May 20, 2018
@renatobecker-zz
Copy link
Author

renatobecker-zz commented May 20, 2018

@sampaiodiego, I will explain to you why I thought that fixing this issue it would fixes the #9278 too.
The request in #9278 is related do Guest Pool routing method, which has a different behaviour from Least Amount method. As you know, using the Least Amount routing method, an incoming chat is redirected to an agent as soon as the chat arrives and when a chat is forward, the same behaviour is used. On the other hand, when the routing method used is Guest Pool, the incoming chat stays waiting an agent take it, so, using the same logic, why forwarding a chat, will it be assigned arbitrary to an agent if the logic of the method is that an agent can choice which chat takes?
Sorry for my long explanation, but analysing the logic in both methods, I thought that if my conclusion was correct, there would not be reason to create another method to deal with open Guest Pool chat's when an agent goes offline, because, IMO, it's exactly what the forward options has to do when in Guest Pool routing method.
If I'm wrong or have forgotten something, please let me know.
I'll be waiting for your feedback.

@sampaiodiego sampaiodiego temporarily deployed to rocket-chat-pr-10731 June 18, 2018 12:47 Inactive
@sampaiodiego sampaiodiego self-assigned this Jun 18, 2018
Copy link
Member

@sampaiodiego sampaiodiego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also find an issue with the new URL scheme for livechats.. when I accept the inquiry I'm being redirect to an invalid URL (without the room _id): http://localhost:3000/live

//In this case, an error is raised, so to avoid this the room user is instantiated
let user = Meteor.user();
if (!user) {
user = RocketChat.models.Users.findOne(room.servedBy._id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you cannot get the room agent at this point because on lines bellow you're validating if the user has permission..

on the validation bellow you must validate against the logged in user who is performing the action.

}

// //delete agent and room subscription
if (!user._id || !RocketChat.authz.hasPermission(user._id, 'view-l-room')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the user is null or undefined this will throw an error.

RocketChat.models.Subscriptions.removeByRoomId(rid);

// remove user from room
const username = Meteor.user().username;
const username = user.username;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this must be the agent and not the logged in user.. imagine a situation where the manager is returning the livechat to the queue.

@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-10731 June 19, 2018 20:51 Inactive
@renatobecker-zz
Copy link
Author

@sampaiodiego, all requested changes are made.

@sampaiodiego
Copy link
Member

can you please fix the conflicts? thx

# Conflicts:
#	packages/rocketchat-livechat/server/methods/returnAsInquiry.js
#	packages/rocketchat-livechat/server/methods/takeInquiry.js
@renatobecker-zz
Copy link
Author

@sampaiodiego,
The conflicts have been fixed.

@theorenck theorenck modified the milestones: 0.67.0, 0.68.0 Jul 19, 2018
@sampaiodiego sampaiodiego merged commit ae393db into develop Jul 21, 2018
@sampaiodiego sampaiodiego deleted the livechat-return-chat-to-the-guest-pool branch July 21, 2018 02:14
@sampaiodiego sampaiodiego mentioned this pull request Jul 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants