backend: Refactor recording timeout handling by extracting timeout registration into a separate method

This commit is contained in:
Carlos Santos 2025-04-22 11:13:30 +02:00
parent 74d1b542b6
commit 47350f1b10

View File

@ -94,17 +94,10 @@ export class RecordingService {
this.taskSchedulerService.cancelTask(`${roomId}_recording_timeout`);
this.systemEventService.off(SystemEventType.RECORDING_ACTIVE, eventListener);
resolve(info as unknown as MeetRecordingInfo);
} else {
this.logger.error('Received recording active event with mismatched recording ID:', info);
}
};
this.taskSchedulerService.registerTask({
name: `${roomId}_recording_timeout`,
type: 'timeout',
scheduleOrDelay: INTERNAL_CONFIG.RECORDING_STARTED_TIMEOUT,
callback: this.handleRecordingLockTimeout.bind(this, recordingId, roomId, eventListener, reject)
});
this.registerRecordingTimeout(roomId, recordingId, eventListener, reject);
this.systemEventService.on(SystemEventType.RECORDING_ACTIVE, eventListener);
});
@ -609,6 +602,20 @@ export class RecordingService {
await this.s3Service.saveObject(metadataPath, recordingInfo);
}
protected registerRecordingTimeout(
roomId: string,
recordingId: string,
eventListener: (info: Record<string, unknown>) => void,
reject: (reason?: unknown) => void
): void {
this.taskSchedulerService.registerTask({
name: `${roomId}_recording_timeout`,
type: 'timeout',
scheduleOrDelay: INTERNAL_CONFIG.RECORDING_STARTED_TIMEOUT,
callback: this.handleRecordingLockTimeout.bind(this, recordingId, roomId, eventListener, reject)
});
}
/**
* Cleans up orphaned recording locks in the system.
*