backend: improve error handling for participant retrieval in LiveKit service and validate room existence in participant deletion

This commit is contained in:
juancarmore 2025-05-15 21:51:54 +02:00
parent 1033382df7
commit 5483004905
2 changed files with 9 additions and 1 deletions

View File

@ -73,9 +73,17 @@ export const refreshParticipantToken = async (req: Request, res: Response) => {
export const deleteParticipant = async (req: Request, res: Response) => {
const logger = container.get(LoggerService);
const roomService = container.get(RoomService);
const participantService = container.get(ParticipantService);
const { roomId, participantName } = req.params;
// Check if the room exists
try {
await roomService.getMeetRoom(roomId);
} catch (error) {
return handleError(res, error, `getting room '${roomId}'`);
}
try {
logger.verbose(`Deleting participant '${participantName}' from room '${roomId}'`);
await participantService.deleteParticipant(participantName, roomId);

View File

@ -158,7 +158,7 @@ export class LiveKitService {
return await this.roomClient.getParticipant(roomName, participantName);
} catch (error) {
this.logger.warn(`Participant ${participantName} not found in room ${roomName}: ${error}`);
throw internalError(`getting participant '${participantName}' in room '${roomName}'`);
throw errorParticipantNotFound(participantName, roomName);
}
}