backend: implement partial update for room repository and adjust service calls accordingly

This commit is contained in:
CSantosM 2026-02-16 09:36:48 +01:00
parent 6d3d19ccd0
commit 5cf2e74eab
2 changed files with 14 additions and 2 deletions

View File

@ -49,6 +49,8 @@ export class RoomRepository<TRoom extends MeetRoom = MeetRoom> extends BaseRepos
* @param room - The complete updated room data
* @returns The updated room with enriched URLs
* @throws Error if room not found
*
* TODO: This method should be renamed to replace or updateFull to better reflect that it replaces the entire document
*/
async update(room: TRoom): Promise<TRoom> {
const normalizedRoom = this.normalizeRoomForStorage(room);
@ -56,6 +58,16 @@ export class RoomRepository<TRoom extends MeetRoom = MeetRoom> extends BaseRepos
return this.enrichRoomWithBaseUrls(document);
}
/**
* TODO: This method should be updated when updatePartial is implemented in the base repository.
* Updates specific fields of a room without replacing the entire document.
* @param roomId
* @param fieldsToUpdate
*/
async updatePartial(roomId: string, fieldsToUpdate: Partial<TRoom>): Promise<void> {
await this.updateOne({ roomId }, fieldsToUpdate);
}
/**
* Finds a room by its roomId.
* Returns the room with enriched URLs (including base URL).

View File

@ -528,7 +528,7 @@ export class RoomService {
if (hasActiveMeeting) {
// Set meeting end action (DELETE or CLOSE) depending on recording policy
room.meetingEndAction = shouldCloseRoom ? MeetingEndAction.CLOSE : MeetingEndAction.DELETE;
await this.roomRepository.update(room);
await this.roomRepository.updatePartial(room.roomId, { meetingEndAction: room.meetingEndAction });
if (shouldForceEndMeeting) {
// Force end meeting by deleting the LiveKit room
@ -541,7 +541,7 @@ export class RoomService {
if (shouldCloseRoom) {
// Close room instead of deleting if recordings exist and policy is CLOSE
room.status = MeetRoomStatus.CLOSED;
await this.roomRepository.update(room);
await this.roomRepository.updatePartial(room.roomId, { status: room.status });
return room;
}