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);
|
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 => {
|
const isMatchingError = (error: OpenViduMeetError, originalError: OpenViduMeetError): boolean => {
|
||||||
return (
|
return (
|
||||||
error instanceof OpenViduMeetError &&
|
error instanceof OpenViduMeetError &&
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import {
|
|||||||
errorRecordingCannotBeStoppedWhileStarting,
|
errorRecordingCannotBeStoppedWhileStarting,
|
||||||
errorRecordingNotFound,
|
errorRecordingNotFound,
|
||||||
errorRecordingNotStopped,
|
errorRecordingNotStopped,
|
||||||
|
errorRoomHasNoParticipants,
|
||||||
errorRoomNotFound,
|
errorRoomNotFound,
|
||||||
internalError,
|
internalError,
|
||||||
isErrorRecordingAlreadyStopped,
|
isErrorRecordingAlreadyStopped,
|
||||||
@ -68,6 +69,11 @@ export class RecordingService {
|
|||||||
|
|
||||||
//TODO: Check if the room has participants before starting the recording
|
//TODO: Check if the room has participants before starting the recording
|
||||||
//room.numParticipants === 0 ? throw errorNoParticipants(roomId);
|
//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.
|
// Attempt to acquire lock. If the lock is not acquired, the recording is already active.
|
||||||
acquiredLock = await this.acquireRoomRecordingActiveLock(roomId);
|
acquiredLock = await this.acquireRoomRecordingActiveLock(roomId);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user