backend: update room configuration schemas for partial updates and default values
This commit is contained in:
parent
45ee463bc6
commit
496591695a
@ -112,17 +112,20 @@ export const AppearanceConfigSchema: z.ZodType<MeetAppearanceConfig> = z.object(
|
||||
themes: z.array(RoomThemeSchema).length(1, 'There must be exactly one theme defined')
|
||||
});
|
||||
|
||||
const RoomConfigSchema: z.ZodType<MeetRoomConfig> = z
|
||||
const RoomConfigSchema: z.ZodType<Partial<MeetRoomConfig>> = z
|
||||
.object({
|
||||
recording: RecordingConfigSchema,
|
||||
chat: ChatConfigSchema,
|
||||
virtualBackground: VirtualBackgroundConfigSchema,
|
||||
recording: RecordingConfigSchema.optional().default({
|
||||
enabled: true,
|
||||
allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER
|
||||
}),
|
||||
chat: ChatConfigSchema.optional().default({ enabled: true }),
|
||||
virtualBackground: VirtualBackgroundConfigSchema.optional().default({ enabled: true }),
|
||||
e2ee: E2EEConfigSchema.optional().default({ enabled: false })
|
||||
// appearance: AppearanceConfigSchema,
|
||||
})
|
||||
.transform((data) => {
|
||||
// Automatically disable recording when E2EE is enabled
|
||||
if (data.e2ee?.enabled && data.recording.enabled) {
|
||||
if (data.e2ee.enabled && data.recording.enabled) {
|
||||
return {
|
||||
...data,
|
||||
recording: {
|
||||
|
||||
@ -46,8 +46,7 @@ const MeetRecordingConfigSchema = new Schema(
|
||||
{
|
||||
enabled: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
default: false
|
||||
required: true
|
||||
},
|
||||
allowAccessTo: {
|
||||
type: String,
|
||||
@ -65,8 +64,7 @@ const MeetChatConfigSchema = new Schema(
|
||||
{
|
||||
enabled: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
default: true
|
||||
required: true
|
||||
}
|
||||
},
|
||||
{ _id: false }
|
||||
@ -79,8 +77,7 @@ const MeetVirtualBackgroundConfigSchema = new Schema(
|
||||
{
|
||||
enabled: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
default: true
|
||||
required: true
|
||||
}
|
||||
},
|
||||
{ _id: false }
|
||||
@ -119,7 +116,8 @@ const MeetRoomConfigSchema = new Schema(
|
||||
},
|
||||
e2ee: {
|
||||
type: MeetE2EEConfigSchema,
|
||||
required: false
|
||||
required: true,
|
||||
default: { enabled: false }
|
||||
}
|
||||
},
|
||||
{ _id: false }
|
||||
|
||||
@ -86,7 +86,7 @@ export class RoomService {
|
||||
// maxParticipants,
|
||||
autoDeletionDate,
|
||||
autoDeletionPolicy,
|
||||
config: config!,
|
||||
config: config! as MeetRoomConfig,
|
||||
moderatorUrl: `/room/${roomId}?secret=${secureUid(10)}`,
|
||||
speakerUrl: `/room/${roomId}?secret=${secureUid(10)}`,
|
||||
status: MeetRoomStatus.OPEN,
|
||||
@ -129,12 +129,13 @@ export class RoomService {
|
||||
|
||||
/**
|
||||
* Updates the configuration of a specific meeting room.
|
||||
* Supports partial updates - only provided fields will be updated.
|
||||
*
|
||||
* @param roomId - The unique identifier of the meeting room to update
|
||||
* @param config - The new config to apply to the meeting room
|
||||
* @param config - Partial config with the fields to update
|
||||
* @returns A Promise that resolves to the updated MeetRoom object
|
||||
*/
|
||||
async updateMeetRoomConfig(roomId: string, config: MeetRoomConfig): Promise<MeetRoom> {
|
||||
async updateMeetRoomConfig(roomId: string, config: Partial<MeetRoomConfig>): Promise<MeetRoom> {
|
||||
const room = await this.getMeetRoom(roomId);
|
||||
|
||||
if (room.status === MeetRoomStatus.ACTIVE_MEETING) {
|
||||
@ -142,7 +143,11 @@ export class RoomService {
|
||||
throw errorRoomActiveMeeting(roomId);
|
||||
}
|
||||
|
||||
room.config = config;
|
||||
// Merge the partial config with the existing config
|
||||
room.config = {
|
||||
...room.config,
|
||||
...config
|
||||
};
|
||||
|
||||
await this.roomRepository.update(room);
|
||||
// Send signal to frontend
|
||||
|
||||
@ -5,7 +5,7 @@ export interface MeetRoomConfig {
|
||||
chat: MeetChatConfig;
|
||||
recording: MeetRecordingConfig;
|
||||
virtualBackground: MeetVirtualBackgroundConfig;
|
||||
e2ee?: MeetE2EEConfig;
|
||||
e2ee: MeetE2EEConfig;
|
||||
// appearance: MeetAppearanceConfig;
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ export interface MeetRoomOptions {
|
||||
roomName?: string;
|
||||
autoDeletionDate?: number;
|
||||
autoDeletionPolicy?: MeetRoomAutoDeletionPolicy;
|
||||
config?: MeetRoomConfig;
|
||||
config?: Partial<MeetRoomConfig>;
|
||||
// maxParticipants?: number | null;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user