Skip to content

Commit

Permalink
fix: LivechatSessionTaken webhook event called without agent param (
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman committed Sep 20, 2024
1 parent 1e52d30 commit 2c2ad3e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
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

0 comments on commit 2c2ad3e

Please sign in to comment.