backend: Implement updateArchivedRoomMetadata method

This commit is contained in:
juancarmore 2025-05-11 14:03:55 +02:00
parent 8b2d0dd34c
commit d62added6e
3 changed files with 51 additions and 1 deletions

View File

@ -274,7 +274,7 @@ export class S3StorageProvider<G extends GlobalPreferences = GlobalPreferences,
* This method checks if the metadata file for the given room already exists in the
* S3 bucket. If not, it retrieves the room information, extracts the necessary
* secrets and preferences, and saves them to a metadata JSON file in the
* .metadata/{roomId}/ directory of the S3 bucket.
* .room_metadata/{roomId}/ directory of the S3 bucket.
*
* @param roomId - The unique identifier of the room
*/
@ -309,6 +309,43 @@ export class S3StorageProvider<G extends GlobalPreferences = GlobalPreferences,
}
}
/**
* Updates the archived room metadata for a given room in the S3 recordings bucket if it exists.
*
* @param roomId - The unique identifier of the room whose metadata needs to be updated.
*/
async updateArchivedRoomMetadata(roomId: string): Promise<void> {
try {
const filePath = `${INTERNAL_CONFIG.S3_RECORDINGS_PREFIX}/.room_metadata/${roomId}/room_metadata.json`;
const fileExists = await this.s3Service.exists(filePath);
if (!fileExists) {
this.logger.warn(`Room metadata not found for room ${roomId} in recordings bucket`);
return;
}
const room = await this.getMeetRoom(roomId);
if (room) {
const roomMetadata = {
moderatorRoomUrl: room.moderatorRoomUrl,
publisherRoomUrl: room.publisherRoomUrl,
preferences: {
recordingPreferences: room.preferences?.recordingPreferences
}
};
await this.s3Service.saveObject(filePath, roomMetadata);
this.logger.debug(`Room metadata updated for room ${roomId} in recordings bucket`);
return;
}
this.logger.error(`Error updating room metadata for room ${roomId} in recordings bucket`);
} catch (error) {
this.logger.error(`Error updating room metadata for room ${roomId} in recordings bucket: ${error}`);
}
}
/**
* Retrieves an object of type U from Redis by the given key.
* Returns null if the key is not found or an error occurs.

View File

@ -98,6 +98,15 @@ export interface StorageProvider<T extends GlobalPreferences = GlobalPreferences
*/
archiveRoomMetadata(roomId: string): Promise<void>;
/**
* Updates the archived metadata for a specific room.
*
* This is necessary for keeping the metadata of a room up to date.
*
* @param roomId: The room ID to update.
*/
updateArchivedRoomMetadata(roomId: string): Promise<void>;
//TODO:
// deleteArchivedRoomMetadata(roomId: string): Promise<void>;

View File

@ -131,6 +131,10 @@ export class MeetStorageService<G extends GlobalPreferences = GlobalPreferences,
return this.storageProvider.archiveRoomMetadata(roomId);
}
async updateArchivedRoomMetadata(roomId: string): Promise<void> {
return this.storageProvider.updateArchivedRoomMetadata(roomId);
}
/**
* Returns the default global preferences.
* @returns {G}