backend: Add error handling for starting recordings when no participants are present
This commit is contained in:
parent
30ee4dfbca
commit
a17bcd5771
@ -75,6 +75,10 @@ export const errorRecordingAlreadyStarted = (roomId: string): OpenViduMeetError
|
||||
return new OpenViduMeetError('Recording Error', `The room '${roomId}' is already being recorded`, 409);
|
||||
};
|
||||
|
||||
export const errorRoomHasNoParticipants = (roomId: string): OpenViduMeetError => {
|
||||
return new OpenViduMeetError('Recording Error', `The room '${roomId}' has no participants`, 409);
|
||||
};
|
||||
|
||||
const isMatchingError = (error: OpenViduMeetError, originalError: OpenViduMeetError): boolean => {
|
||||
return (
|
||||
error instanceof OpenViduMeetError &&
|
||||
|
||||
@ -9,6 +9,7 @@ import {
|
||||
errorRecordingCannotBeStoppedWhileStarting,
|
||||
errorRecordingNotFound,
|
||||
errorRecordingNotStopped,
|
||||
errorRoomHasNoParticipants,
|
||||
errorRoomNotFound,
|
||||
internalError,
|
||||
isErrorRecordingAlreadyStopped,
|
||||
@ -68,6 +69,11 @@ export class RecordingService {
|
||||
|
||||
//TODO: Check if the room has participants before starting the recording
|
||||
//room.numParticipants === 0 ? throw errorNoParticipants(roomId);
|
||||
const lkRoom = await this.livekitService.getRoom(roomId);
|
||||
|
||||
if (!lkRoom) throw errorRoomNotFound(roomId);
|
||||
|
||||
if (lkRoom.numParticipants === 0) throw errorRoomHasNoParticipants(roomId);
|
||||
|
||||
// Attempt to acquire lock. If the lock is not acquired, the recording is already active.
|
||||
acquiredLock = await this.acquireRoomRecordingActiveLock(roomId);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user