Skip to content

Commit

Permalink
backend: Improved the webhook handler
Browse files Browse the repository at this point in the history
  • Loading branch information
CSantosM committed Jul 8, 2024
1 parent 7fd794e commit 58241eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions openvidu-call-back/src/controllers/webhook.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ export const webhookHandler = async (req: Request, res: Response) => {

function getRoomOrRoomName(webhookEvent: WebhookEvent) {
const { room, egressInfo, ingressInfo } = webhookEvent;
const roomName = room?.name ?? egressInfo?.roomName ?? ingressInfo?.roomName ?? '';

// KNOWN issue: room metadata is empty when track_publish and track_unpublish events are received
// !KNOWN issue: room metadata is empty when track_publish and track_unpublish events are received
// This not affect OpenVidu Call, but it is a limitation of the LiveKit server
return room ?? egressInfo?.roomName ?? ingressInfo?.roomName ?? '';

// Prefer webhook room object over roomName if available
return room ?? roomName;
}
7 changes: 6 additions & 1 deletion openvidu-call-back/src/services/room.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,17 @@ export class RoomService {
room = await this.getRoom(roomOrRoomName);
} else {
room = roomOrRoomName;

// !KNOWN issue: room metadata is empty when track_publish and track_unpublish events are received
if (!room.metadata) {
room = await this.getRoom(room.name);
}
}

const metadata = room.metadata ? JSON.parse(room.metadata) : null;
return metadata?.createdBy === CALL_NAME_ID;
} catch (error) {
console.error('Error in isRoomCreatedByMe:', error);
console.warn('Error getting Room while parsing webhook checking if isRoomCreatedByMe:', error);
return false;
}
}
Expand Down

0 comments on commit 58241eb

Please sign in to comment.