backend: update archiveRoomMetadata method to conditionally update existing metadata
This commit is contained in:
parent
8df8fa216b
commit
f5718d0da4
@ -131,7 +131,7 @@ export class RoomService {
|
|||||||
|
|
||||||
await this.storageService.saveMeetRoom(room);
|
await this.storageService.saveMeetRoom(room);
|
||||||
// Update the archived room metadata if it exists
|
// Update the archived room metadata if it exists
|
||||||
await this.storageService.archiveRoomMetadata(roomId);
|
await this.storageService.archiveRoomMetadata(roomId, true);
|
||||||
return room;
|
return room;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -242,13 +242,15 @@ export class MeetStorageService<
|
|||||||
* This method retrieves the room data, extracts key metadata (moderator/publisher URLs and
|
* This method retrieves the room data, extracts key metadata (moderator/publisher URLs and
|
||||||
* recording preferences), and saves it to an archived location for future reference.
|
* recording preferences), and saves it to an archived location for future reference.
|
||||||
*
|
*
|
||||||
* If an archived metadata for the room already exists, it will be overwritten.
|
* If `updateOnlyIfExists` is true, it will only save the archived metadata if it already exists,
|
||||||
|
* updating the existing entry.
|
||||||
*
|
*
|
||||||
* @param roomId - The unique identifier of the room to archive
|
* @param roomId - The unique identifier of the room to archive
|
||||||
|
* @param updateOnlyIfExists - If true, only update if archived metadata already exists
|
||||||
* @throws {Error} When the room with the specified ID is not found
|
* @throws {Error} When the room with the specified ID is not found
|
||||||
* @returns A promise that resolves when the archiving operation completes successfully
|
* @returns A promise that resolves when the archiving operation completes successfully
|
||||||
*/
|
*/
|
||||||
async archiveRoomMetadata(roomId: string): Promise<void> {
|
async archiveRoomMetadata(roomId: string, updateOnlyIfExists = false): Promise<void> {
|
||||||
const redisKey = RedisKeyName.ARCHIVED_ROOM + roomId;
|
const redisKey = RedisKeyName.ARCHIVED_ROOM + roomId;
|
||||||
const storageKey = this.keyBuilder.buildArchivedMeetRoomKey(roomId);
|
const storageKey = this.keyBuilder.buildArchivedMeetRoomKey(roomId);
|
||||||
|
|
||||||
@ -259,6 +261,15 @@ export class MeetStorageService<
|
|||||||
throw errorRoomNotFound(roomId);
|
throw errorRoomNotFound(roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updateOnlyIfExists) {
|
||||||
|
const existing = await this.getFromCacheAndStorage<Partial<MRoom>>(redisKey, storageKey);
|
||||||
|
|
||||||
|
if (!existing) {
|
||||||
|
this.logger.verbose(`Archived metadata for room ${roomId} does not exist, skipping update`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const archivedRoom: Partial<MRoom> = {
|
const archivedRoom: Partial<MRoom> = {
|
||||||
moderatorRoomUrl: room.moderatorRoomUrl,
|
moderatorRoomUrl: room.moderatorRoomUrl,
|
||||||
publisherRoomUrl: room.publisherRoomUrl,
|
publisherRoomUrl: room.publisherRoomUrl,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user