openvidu-recording-improved: Check if room is active before sending data message when recording is deleted
This commit is contained in:
parent
44f0c4fb81
commit
ea89874179
@ -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);
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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)]);
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user