backend: add getRecordingMetadataByPath method to StorageProvider and implement in S3StorageProvider and MeetStorageService

This commit is contained in:
Carlos Santos 2025-05-29 16:19:27 +02:00
parent 52ef54311a
commit 0fc8c203dd
4 changed files with 47 additions and 2 deletions

View File

@ -363,11 +363,13 @@ export class RecordingService {
// Retrieve the metadata for each recording // Retrieve the metadata for each recording
Contents.forEach((item) => { Contents.forEach((item) => {
if (item?.Key && item.Key.endsWith('.json') && !item.Key.endsWith('secrets.json')) { if (item?.Key && item.Key.endsWith('.json') && !item.Key.endsWith('secrets.json')) {
promises.push(this.s3Service.getObjectAsJson(item.Key) as Promise<MeetRecordingInfo>); promises.push(
this.storageService.getRecordingMetadataByPath(item.Key) as Promise<MeetRecordingInfo>
);
} }
}); });
let recordings: MeetRecordingInfo[] = await Promise.all(promises); let recordings = await Promise.all(promises);
recordings = recordings.map((rec) => UtilsHelper.filterObjectFields(rec, fields)) as MeetRecordingInfo[]; recordings = recordings.map((rec) => UtilsHelper.filterObjectFields(rec, fields)) as MeetRecordingInfo[];

View File

@ -437,6 +437,24 @@ export class S3StorageProvider<
} }
} }
/**
* Retrieves recording metadata from S3 storage by the specified path.
*
* @param recordingPath - The S3 path where the recording metadata is stored
* @returns A promise that resolves to the recording metadata object
* @throws Will throw an error if the S3 object retrieval fails or if the path is invalid
*/
async getRecordingMetadataByPath(recordingPath: string): Promise<MRec> {
try {
return await this.s3Service.getObjectAsJson(recordingPath) as MRec;
} catch (error) {
this.handleError(error, `Error fetching recording metadata for path ${recordingPath}`);
throw error;
}
}
async saveRecordingMetadata(recordingInfo: MRec): Promise<MRec> { async saveRecordingMetadata(recordingInfo: MRec): Promise<MRec> {
try { try {
const metadataPath = RecordingHelper.buildMetadataFilePath(recordingInfo.recordingId); const metadataPath = RecordingHelper.buildMetadataFilePath(recordingInfo.recordingId);

View File

@ -143,6 +143,14 @@ export interface StorageProvider<
*/ */
getRecordingMetadata(recordingId: string): Promise<{ recordingInfo: MRec; metadataFilePath: string }>; getRecordingMetadata(recordingId: string): Promise<{ recordingInfo: MRec; metadataFilePath: string }>;
/**
* Retrieves the recording metadata for multiple recording IDs.
*
* @param recordingPath - The path of the recording file to retrieve metadata for.
* @returns A promise that resolves to the recording metadata, or null if not found.
*/
getRecordingMetadataByPath(recordingPath: string): Promise<MRec | undefined>;
/** /**
* Deletes multiple recording metadata files by their paths. * Deletes multiple recording metadata files by their paths.
* *

View File

@ -215,6 +215,13 @@ export class MeetStorageService<
return this.storageProvider.saveRecordingMetadata(recordingInfo) as Promise<MRec>; return this.storageProvider.saveRecordingMetadata(recordingInfo) as Promise<MRec>;
} }
/**
* Retrieves the metadata for a specific recording.
*
* @param recordingId - The unique identifier of the recording
* @returns A promise that resolves to an object containing the recording information and metadata file path
* @throws May throw an error if the recording is not found or if there's an issue accessing the storage provider
*/
async getRecordingMetadata(recordingId: string): Promise<{ recordingInfo: MRec; metadataFilePath: string }> { async getRecordingMetadata(recordingId: string): Promise<{ recordingInfo: MRec; metadataFilePath: string }> {
return this.storageProvider.getRecordingMetadata(recordingId) as Promise<{ return this.storageProvider.getRecordingMetadata(recordingId) as Promise<{
recordingInfo: MRec; recordingInfo: MRec;
@ -222,6 +229,16 @@ export class MeetStorageService<
}>; }>;
} }
/**
* Retrieves metadata for recordings by their file path.
*
* @param recordingPath - The path of the recording file to retrieve metadata for
* @returns A promise that resolves to
*/
async getRecordingMetadataByPath(recordingPath: string): Promise<MRec | undefined> {
return this.storageProvider.getRecordingMetadataByPath(recordingPath) as Promise<MRec>;
}
/** /**
* Retrieves recording media as a readable stream from the storage provider. * Retrieves recording media as a readable stream from the storage provider.
* *