feat: cal video settings (#21347)
* feat: cal video settings * fix: var names * feat: finish setting * chore: add enabled * chore: remove logs * feat: support redirect url on exit * feat: finish settings * refactor: improve UI * chore: remove logs * fix: type err * fix: finish redirect url * fix: add type * chore: change schema * fix: type error * chore: improvements * chore: remove index * feat: add organizer * chore: remove log * chore: use safe parse * fix: add nullable * refactor: hide toggles if platorm * chore: update description --------- Co-authored-by: Alex van Andel <[email protected]> Co-authored-by: supalarry <[email protected]>
This commit is contained in:
16 files changed
+329
-23
No files matched your search
@@ -25,6 +25,15 @@ const aiPhoneCallConfig = z
|
||||
})
|
||||
.optional();
|
||||
|
||||
const calVideoSettingsSchema = z
|
||||
.object({
|
||||
disableRecordingForGuests: z.boolean().optional().nullable(),
|
||||
disableRecordingForOrganizer: z.boolean().optional().nullable(),
|
||||
redirectUrlOnExit: z.string().url().optional().nullable(),
|
||||
})
|
||||
.optional()
|
||||
.nullable();
|
||||
|
||||
const hostSchema = z.object({
|
||||
userId: z.number(),
|
||||
profileId: z.number().or(z.null()).optional(),
|
||||
@@ -51,6 +60,7 @@ const BaseEventTypeUpdateInput = _EventTypeModel
|
||||
instantMeetingParameters: z.array(z.string()),
|
||||
instantMeetingExpiryTimeOffsetInSeconds: z.number(),
|
||||
aiPhoneCallConfig,
|
||||
calVideoSettings: calVideoSettingsSchema,
|
||||
calAiPhoneScript: z.string(),
|
||||
customInputs: z.array(customInputSchema),
|
||||
destinationCalendar: _DestinationCalendarModel
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Prisma } from "@prisma/client";
|
||||
import type { NextApiResponse, GetServerSidePropsContext } from "next";
|
||||
|
||||
import type { appDataSchemas } from "@calcom/app-store/apps.schemas.generated";
|
||||
import { DailyLocationType } from "@calcom/app-store/locations";
|
||||
import updateChildrenEventTypes from "@calcom/features/ee/managed-event-types/lib/handleChildrenEventTypes";
|
||||
import {
|
||||
allowDisablingAttendeeConfirmationEmails,
|
||||
@@ -11,11 +12,13 @@ import tasker from "@calcom/features/tasker";
|
||||
import { validateIntervalLimitOrder } from "@calcom/lib/intervalLimits/validateIntervalLimitOrder";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||
import { CalVideoSettingsRepository } from "@calcom/lib/server/repository/calVideoSettings";
|
||||
import { validateBookerLayouts } from "@calcom/lib/validateBookerLayouts";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
import { WorkflowTriggerEvents } from "@calcom/prisma/client";
|
||||
import { SchedulingType, EventTypeAutoTranslatedField } from "@calcom/prisma/enums";
|
||||
import { eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils";
|
||||
import { eventTypeLocations } from "@calcom/prisma/zod-utils";
|
||||
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
||||
@@ -83,6 +86,7 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
description: newDescription,
|
||||
title: newTitle,
|
||||
seatsPerTimeSlot,
|
||||
calVideoSettings,
|
||||
...rest
|
||||
} = input;
|
||||
|
||||
@@ -90,6 +94,7 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
where: { id },
|
||||
select: {
|
||||
title: true,
|
||||
locations: true,
|
||||
description: true,
|
||||
seatsPerTimeSlot: true,
|
||||
recurringEvent: true,
|
||||
@@ -115,6 +120,13 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
llmId: true,
|
||||
},
|
||||
},
|
||||
calVideoSettings: {
|
||||
select: {
|
||||
disableRecordingForOrganizer: true,
|
||||
disableRecordingForGuests: true,
|
||||
redirectUrlOnExit: true,
|
||||
},
|
||||
},
|
||||
children: {
|
||||
select: {
|
||||
userId: true,
|
||||
@@ -518,6 +530,24 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (calVideoSettings) {
|
||||
await CalVideoSettingsRepository.createOrUpdateCalVideoSettings({
|
||||
eventTypeId: id,
|
||||
calVideoSettings,
|
||||
});
|
||||
}
|
||||
|
||||
const parsedEventTypeLocations = eventTypeLocations.safeParse(eventType.locations ?? []);
|
||||
|
||||
const isCalVideoLocationActive = locations
|
||||
? locations.some((location) => location.type === DailyLocationType)
|
||||
: parsedEventTypeLocations.success &&
|
||||
parsedEventTypeLocations.data?.some((location) => location.type === DailyLocationType);
|
||||
|
||||
if (eventType.calVideoSettings && !isCalVideoLocationActive) {
|
||||
await CalVideoSettingsRepository.deleteCalVideoSettings(id);
|
||||
}
|
||||
|
||||
// Logic for updating `fieldTranslations`
|
||||
// user has no translations OR user is changing the field
|
||||
const hasNoDescriptionTranslations =
|
||||
|
||||
Reference in new issue
Block a user