[FIX] Send Livechat back to Guest Pool#10731
Conversation
| 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); |
There was a problem hiding this comment.
oh... this is an important fix.
sampaiodiego
left a comment
There was a problem hiding this comment.
this does not closes #9278 .. the change requested was to add an option to the following setting:

also, why transfering a chat should send it back to the pool? there is a button specially for this..
|
@sampaiodiego, I will explain to you why I thought that fixing this issue it would fixes the #9278 too. |
sampaiodiego
left a comment
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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')) { |
There was a problem hiding this comment.
if the user is null or undefined this will throw an error.
|
|
||
| // remove user from room | ||
| const username = Meteor.user().username; | ||
| const username = user.username; |
There was a problem hiding this comment.
this must be the agent and not the logged in user.. imagine a situation where the manager is returning the livechat to the queue.
…ocketChat/Rocket.Chat into livechat-return-chat-to-the-guest-pool
|
@sampaiodiego, all requested changes are made. |
|
can you please fix the conflicts? thx |
# Conflicts: # packages/rocketchat-livechat/server/methods/returnAsInquiry.js # packages/rocketchat-livechat/server/methods/takeInquiry.js
|
@sampaiodiego, |
Closes #7397
Closes #9278
Closes #11347
This PR fixes the
forward chatin Livechat rooms when using theGuest Poolrouting 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_actionsetting is set toforward.