backend: add partial update method for recordings and refactor update logic
This commit is contained in:
parent
54bb06adfd
commit
59c464387b
@ -63,13 +63,25 @@ export class RecordingRepository extends BaseRepository<MeetRecordingInfo, MeetR
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing recording.
|
||||
* Updates specific fields of a recording without replacing the entire document.
|
||||
*
|
||||
* @param recordingId - The recording identifier
|
||||
* @param fieldsToUpdate - Partial recording data with fields to update
|
||||
* @returns The updated recording (without access secrets)
|
||||
* @throws Error if recording not found
|
||||
*/
|
||||
async updatePartial(recordingId: string, fieldsToUpdate: Partial<MeetRecordingInfo>): Promise<MeetRecordingInfo> {
|
||||
return this.updatePartialOne({ recordingId }, fieldsToUpdate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces an existing recording with new data.
|
||||
*
|
||||
* @param recording - The recording data to update
|
||||
* @returns The updated recording (without access secrets)
|
||||
* @throws Error if recording not found
|
||||
*/
|
||||
async update(recording: MeetRecordingInfo): Promise<MeetRecordingInfo> {
|
||||
async replace(recording: MeetRecordingInfo): Promise<MeetRecordingInfo> {
|
||||
return this.replaceOne({ recordingId: recording.recordingId }, recording);
|
||||
}
|
||||
|
||||
|
||||
@ -316,7 +316,7 @@ export class LivekitWebhookService {
|
||||
recordingTask = this.recordingRepository.create(recordingInfo);
|
||||
} else {
|
||||
// Update existing recording
|
||||
recordingTask = this.recordingRepository.update(recordingInfo);
|
||||
recordingTask = this.recordingRepository.replace(recordingInfo);
|
||||
}
|
||||
|
||||
const commonTasks = [recordingTask];
|
||||
|
||||
@ -563,9 +563,9 @@ export class RecordingService {
|
||||
}
|
||||
|
||||
async updateRecordingStatus(recordingId: string, status: MeetRecordingStatus): Promise<void> {
|
||||
const recordingInfo = await this.getRecording(recordingId);
|
||||
recordingInfo.status = status;
|
||||
await this.recordingRepository.update(recordingInfo);
|
||||
// Ensure recording exists before updating
|
||||
await this.getRecording(recordingId, ['recordingId']);
|
||||
await this.recordingRepository.updatePartial(recordingId, { status });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user