backend: improve error handling for participant retrieval in LiveKit service and validate room existence in participant deletion
This commit is contained in:
parent
1033382df7
commit
5483004905
@ -73,9 +73,17 @@ export const refreshParticipantToken = async (req: Request, res: Response) => {
|
|||||||
|
|
||||||
export const deleteParticipant = async (req: Request, res: Response) => {
|
export const deleteParticipant = async (req: Request, res: Response) => {
|
||||||
const logger = container.get(LoggerService);
|
const logger = container.get(LoggerService);
|
||||||
|
const roomService = container.get(RoomService);
|
||||||
const participantService = container.get(ParticipantService);
|
const participantService = container.get(ParticipantService);
|
||||||
const { roomId, participantName } = req.params;
|
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 {
|
try {
|
||||||
logger.verbose(`Deleting participant '${participantName}' from room '${roomId}'`);
|
logger.verbose(`Deleting participant '${participantName}' from room '${roomId}'`);
|
||||||
await participantService.deleteParticipant(participantName, roomId);
|
await participantService.deleteParticipant(participantName, roomId);
|
||||||
|
|||||||
@ -158,7 +158,7 @@ export class LiveKitService {
|
|||||||
return await this.roomClient.getParticipant(roomName, participantName);
|
return await this.roomClient.getParticipant(roomName, participantName);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.warn(`Participant ${participantName} not found in room ${roomName}: ${error}`);
|
this.logger.warn(`Participant ${participantName} not found in room ${roomName}: ${error}`);
|
||||||
throw internalError(`getting participant '${participantName}' in room '${roomName}'`);
|
throw errorParticipantNotFound(participantName, roomName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user