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: LivechatSessionTaken webhook event called without agent param #33209

Merged
merged 4 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions .changeset/spicy-rocks-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed `LivechatSessionTaken` webhook event being called without the `agent` param, which represents the agent serving the room.
15 changes: 12 additions & 3 deletions apps/meteor/app/livechat/server/lib/RoutingManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,20 @@ export const RoutingManager: Routing = {

logger.info(`Inquiry ${inquiry._id} taken by agent ${agent.agentId}`);

// assignAgent changes the room data to add the agent serving the conversation. afterTakeInquiry expects room object to be updated
const inq = await this.assignAgent(inquiry as InquiryWithAgentInfo, room, agent);
const roomAfterUpdate = await LivechatRooms.findOneById(rid);

if (!roomAfterUpdate) {
// This should never happen
throw new Error('error-room-not-found');
}

callbacks.runAsync(
'livechat.afterTakeInquiry',
{
inquiry: await this.assignAgent(inquiry as InquiryWithAgentInfo, room, agent),
room,
inquiry: inq,
room: roomAfterUpdate,
},
agent,
);
Expand All @@ -282,7 +291,7 @@ export const RoutingManager: Routing = {
queuedAt: undefined,
});

return LivechatRooms.findOneById(rid);
return roomAfterUpdate;
},

async transferRoom(room, guest, transferData) {
Expand Down
Loading