backend: enhance room configuration schemas for updates and creation
This commit is contained in:
parent
0ba9d0b297
commit
be5e3ffb1d
@ -92,7 +92,11 @@ 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<Partial<MeetRoomConfig>> = z
|
||||
/**
|
||||
* Schema for updating room config (partial updates allowed)
|
||||
* Used when updating an existing room's config - missing fields keep their current values
|
||||
*/
|
||||
const UpdateRoomConfigSchema: z.ZodType<Partial<MeetRoomConfig>> = z
|
||||
.object({
|
||||
recording: RecordingConfigSchema.optional(),
|
||||
chat: ChatConfigSchema.optional(),
|
||||
@ -100,7 +104,7 @@ const RoomConfigSchema: z.ZodType<Partial<MeetRoomConfig>> = z
|
||||
e2ee: E2EEConfigSchema.optional()
|
||||
// appearance: AppearanceConfigSchema,
|
||||
})
|
||||
.transform((data) => {
|
||||
.transform((data: Partial<MeetRoomConfig>) => {
|
||||
// Automatically disable recording when E2EE is enabled
|
||||
if (data.e2ee?.enabled && data.recording?.enabled) {
|
||||
data.recording = {
|
||||
@ -112,6 +116,30 @@ const RoomConfigSchema: z.ZodType<Partial<MeetRoomConfig>> = z
|
||||
return data;
|
||||
});
|
||||
|
||||
/**
|
||||
* Schema for creating room config (applies defaults for missing fields)
|
||||
* Used when creating a new room - missing fields get default values
|
||||
*/
|
||||
const CreateRoomConfigSchema = z
|
||||
.object({
|
||||
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) {
|
||||
data.recording = {
|
||||
...data.recording,
|
||||
enabled: false
|
||||
};
|
||||
}
|
||||
|
||||
return data as MeetRoomConfig;
|
||||
});
|
||||
|
||||
const RoomDeletionPolicyWithMeetingSchema: z.ZodType<MeetRoomDeletionPolicyWithMeeting> = z.nativeEnum(
|
||||
MeetRoomDeletionPolicyWithMeeting
|
||||
);
|
||||
@ -163,7 +191,7 @@ export const RoomOptionsSchema: z.ZodType<MeetRoomOptions> = z.object({
|
||||
path: ['withRecordings']
|
||||
}
|
||||
),
|
||||
config: RoomConfigSchema.optional().default({
|
||||
config: CreateRoomConfigSchema.optional().default({
|
||||
recording: { enabled: true, allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER },
|
||||
chat: { enabled: true },
|
||||
virtualBackground: { enabled: true },
|
||||
@ -241,7 +269,7 @@ export const BulkDeleteRoomsReqSchema = z.object({
|
||||
});
|
||||
|
||||
export const UpdateRoomConfigReqSchema = z.object({
|
||||
config: RoomConfigSchema
|
||||
config: UpdateRoomConfigSchema
|
||||
});
|
||||
|
||||
export const UpdateRoomStatusReqSchema = z.object({
|
||||
|
||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@ -50,6 +50,9 @@ importers:
|
||||
'@livekit/track-processors':
|
||||
specifier: ^0.7.0
|
||||
version: 0.7.0(@types/dom-mediacapture-transform@0.1.11)(livekit-client@2.16.1(@types/dom-mediacapture-record@1.0.22))
|
||||
'@types/dom-mediacapture-transform':
|
||||
specifier: 0.1.11
|
||||
version: 0.1.11
|
||||
autolinker:
|
||||
specifier: ^4.0.0
|
||||
version: 4.1.5
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user