openvidu-recording-improved: Check if room is active before sending data message when recording is deleted

This commit is contained in:
juancarmore 2024-09-17 17:17:15 +02:00
parent 44f0c4fb81
commit ea89874179
4 changed files with 14 additions and 4 deletions

View File

@ -110,7 +110,12 @@ recordingController.delete("/:recordingName", async (req, res) => {
await recordingService.deleteRecording(recordingName);
// Notify to all participants that the recording was deleted
await roomService.sendDataToRoom(roomName, { recordingName });
const existsRoom = await roomService.exists(roomName);
if (existsRoom) {
await roomService.sendDataToRoom(roomName, { recordingName });
}
res.json({ message: "Recording deleted" });
} catch (error) {
console.error("Error deleting recording.", error);

View File

@ -31,9 +31,9 @@ roomController.post("/", async (req, res) => {
try {
// Create room if it doesn't exist
const room = await roomService.getRoom(roomName);
const exists = await roomService.exists(roomName);
if (!room) {
if (!exists) {
await roomService.createRoom(roomName);
}
} catch (error) {

View File

@ -80,7 +80,7 @@ export class RecordingService {
}
async deleteRecording(recordingName) {
const recordingKey = RECORDINGS_PATH + recordingName;
const recordingKey = this.getRecordingKey(recordingName);
const metadataKey = this.getMetadataKey(recordingName);
// Delete the recording file and metadata file from S3
await Promise.all([s3Service.deleteObject(recordingKey), s3Service.deleteObject(metadataKey)]);

View File

@ -32,6 +32,11 @@ export class RoomService {
return rooms.length > 0 ? rooms[0] : null;
}
async exists(roomName) {
const room = await this.getRoom(roomName);
return room !== null;
}
async updateRoomMetadata(roomName, recordingStatus) {
const metadata = {
createdBy: APP_NAME,