feat: support updating cal video settings in API v2 (#21784)
* feat: support updating cal video settings in API v2 * chore: update descriptio * feat: support create event type * test: add test for updating event type * test: add test for create event type * chore: undo openapi * chore: bump libraries * Revert "chore: bump libraries" This reverts commit bdf36d09b021fc531497a7b7ea66ab9c52b7d136. * chore: bump libraries --------- Co-authored-by: Lauris Skraucis <[email protected]> Co-authored-by: supalarry <[email protected]>
This commit is contained in:
15 files changed
+669
-2443
No files matched your search
@@ -125,6 +125,9 @@ export class EventTypeRepository {
|
||||
static async create(data: IEventType) {
|
||||
return await prisma.eventType.create({
|
||||
data: this.generateCreateEventTypeData(data),
|
||||
include: {
|
||||
calVideoSettings: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+36
-3
@@ -124,6 +124,29 @@ export const CREATE_EVENT_SLUG_EXAMPLE = "learn-the-secrets-of-masterchief";
|
||||
RescheduleReasonDefaultFieldInput_2024_06_14,
|
||||
InputOrganizersDefaultApp_2024_06_14
|
||||
)
|
||||
export class CalVideoSettings {
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
@DocsPropertyOptional({
|
||||
description: "If true, the organizer will not be able to record the meeting",
|
||||
})
|
||||
disableRecordingForOrganizer?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
@DocsPropertyOptional({
|
||||
description: "If true, the guests will not be able to record the meeting",
|
||||
})
|
||||
disableRecordingForGuests?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsUrl()
|
||||
@DocsPropertyOptional({
|
||||
description: "URL to which participants are redirected when they exit the call",
|
||||
})
|
||||
redirectUrlOnExit?: string | null;
|
||||
}
|
||||
|
||||
class BaseCreateEventTypeInput {
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@@ -369,9 +392,9 @@ class BaseCreateEventTypeInput {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@DocsPropertyOptional({
|
||||
description: `Customizable event name with valid variables:
|
||||
{Event type title}, {Organiser}, {Scheduler}, {Location}, {Organiser first name},
|
||||
{Scheduler first name}, {Scheduler last name}, {Event duration}, {LOCATION},
|
||||
description: `Customizable event name with valid variables:
|
||||
{Event type title}, {Organiser}, {Scheduler}, {Location}, {Organiser first name},
|
||||
{Scheduler first name}, {Scheduler last name}, {Event duration}, {LOCATION},
|
||||
{HOST/ATTENDEE}, {HOST}, {ATTENDEE}, {USER}`,
|
||||
example: "{Event type title} between {Organiser} and {Scheduler}",
|
||||
})
|
||||
@@ -407,6 +430,15 @@ class BaseCreateEventTypeInput {
|
||||
"Boolean to Hide organizer's email address from the booking screen, email notifications, and calendar events",
|
||||
})
|
||||
hideOrganizerEmail?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => CalVideoSettings)
|
||||
@DocsPropertyOptional({
|
||||
description: "Cal video settings for the event type",
|
||||
type: CalVideoSettings,
|
||||
})
|
||||
calVideoSettings?: CalVideoSettings;
|
||||
}
|
||||
export class CreateEventTypeInput_2024_06_14 extends BaseCreateEventTypeInput {
|
||||
@IsOptional()
|
||||
@@ -457,6 +489,7 @@ export class Host {
|
||||
@DocsPropertyOptional({ enum: HostPriority })
|
||||
priority?: keyof typeof HostPriority = "medium";
|
||||
}
|
||||
|
||||
export class CreateTeamEventTypeInput_2024_06_14 extends BaseCreateEventTypeInput {
|
||||
@Transform(({ value }) => {
|
||||
if (value === "collective") {
|
||||
|
||||
+10
@@ -63,6 +63,7 @@ import {
|
||||
CREATE_EVENT_SLUG_EXAMPLE,
|
||||
CREATE_EVENT_TITLE_EXAMPLE,
|
||||
Host,
|
||||
CalVideoSettings,
|
||||
} from "./create-event-type.input";
|
||||
import { DestinationCalendar_2024_06_14 } from "./destination-calendar.input";
|
||||
import { Disabled_2024_06_14 } from "./disabled.input";
|
||||
@@ -404,6 +405,15 @@ class BaseUpdateEventTypeInput {
|
||||
"Boolean to Hide organizer's email address from the booking screen, email notifications, and calendar events",
|
||||
})
|
||||
hideOrganizerEmail?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => CalVideoSettings)
|
||||
@DocsPropertyOptional({
|
||||
description: "Cal video settings for the event type",
|
||||
type: CalVideoSettings,
|
||||
})
|
||||
calVideoSettings?: CalVideoSettings;
|
||||
}
|
||||
export class UpdateEventTypeInput_2024_06_14 extends BaseUpdateEventTypeInput {
|
||||
@IsOptional()
|
||||
|
||||
+10
@@ -27,6 +27,7 @@ import {
|
||||
BusinessDaysWindow_2024_06_14,
|
||||
CalendarDaysWindow_2024_06_14,
|
||||
RangeWindow_2024_06_14,
|
||||
CalVideoSettings,
|
||||
} from "../inputs";
|
||||
import { Recurrence_2024_06_14 } from "../inputs";
|
||||
import { BookerLayouts_2024_06_14 } from "../inputs/booker-layouts.input";
|
||||
@@ -429,6 +430,15 @@ class BaseEventTypeOutput_2024_06_14 {
|
||||
"Boolean to Hide organizer's email address from the booking screen, email notifications, and calendar events",
|
||||
})
|
||||
hideOrganizerEmail?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => CalVideoSettings)
|
||||
@ApiPropertyOptional({
|
||||
description: "Cal video settings for the event type",
|
||||
type: CalVideoSettings,
|
||||
})
|
||||
calVideoSettings?: CalVideoSettings | null;
|
||||
}
|
||||
|
||||
export class TeamEventTypeResponseHost extends TeamEventTypeHostInput {
|
||||
|
||||
@@ -5,6 +5,15 @@ import { MIN_EVENT_DURATION_MINUTES, MAX_EVENT_DURATION_MINUTES } from "@calcom/
|
||||
// TODO: figure out why EventTypeModel is being called even if it's not imported here, causing a circular dependency
|
||||
// import { _EventTypeModel } from "../eventtype";
|
||||
|
||||
const calVideoSettingsSchema = z
|
||||
.object({
|
||||
disableRecordingForGuests: z.boolean().optional().nullable(),
|
||||
disableRecordingForOrganizer: z.boolean().optional().nullable(),
|
||||
redirectUrlOnExit: z.string().url().optional().nullable(),
|
||||
})
|
||||
.optional()
|
||||
.nullable();
|
||||
|
||||
export const createEventTypeInput = z.object({
|
||||
title: z.string().min(1),
|
||||
slug: imports.eventTypeSlug,
|
||||
@@ -20,7 +29,8 @@ export const createEventTypeInput = z.object({
|
||||
minimumBookingNotice: z.number().int().min(0).optional(),
|
||||
beforeEventBuffer: z.number().int().min(0).optional(),
|
||||
afterEventBuffer: z.number().int().min(0).optional(),
|
||||
scheduleId: z.number().int().optional()
|
||||
scheduleId: z.number().int().optional(),
|
||||
calVideoSettings: calVideoSettingsSchema
|
||||
})
|
||||
.partial({ hidden: true, locations: true })
|
||||
.refine((data) => (data.teamId ? data.teamId && data.schedulingType : true), {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Prisma } from "@prisma/client";
|
||||
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library";
|
||||
|
||||
import { DailyLocationType } from "@calcom/app-store/locations";
|
||||
import { getDefaultLocations } from "@calcom/lib/server/getDefaultLocations";
|
||||
import { EventTypeRepository } from "@calcom/lib/server/repository/eventType";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
@@ -36,7 +37,15 @@ type CreateOptions = {
|
||||
};
|
||||
|
||||
export const createHandler = async ({ ctx, input }: CreateOptions) => {
|
||||
const { schedulingType, teamId, metadata, locations: inputLocations, scheduleId, ...rest } = input;
|
||||
const {
|
||||
schedulingType,
|
||||
teamId,
|
||||
metadata,
|
||||
locations: inputLocations,
|
||||
scheduleId,
|
||||
calVideoSettings,
|
||||
...rest
|
||||
} = input;
|
||||
|
||||
const userId = ctx.user.id;
|
||||
const isManagedEventType = schedulingType === SchedulingType.MANAGED;
|
||||
@@ -45,6 +54,8 @@ export const createHandler = async ({ ctx, input }: CreateOptions) => {
|
||||
const locations: EventTypeLocation[] =
|
||||
inputLocations && inputLocations.length !== 0 ? inputLocations : await getDefaultLocations(ctx.user);
|
||||
|
||||
const isCalVideoLocationActive = locations.some((location) => location.type === DailyLocationType);
|
||||
|
||||
const data: Prisma.EventTypeCreateInput = {
|
||||
...rest,
|
||||
owner: teamId ? undefined : { connect: { id: userId } },
|
||||
@@ -55,6 +66,16 @@ export const createHandler = async ({ ctx, input }: CreateOptions) => {
|
||||
schedule: scheduleId ? { connect: { id: scheduleId } } : undefined,
|
||||
};
|
||||
|
||||
if (isCalVideoLocationActive && calVideoSettings) {
|
||||
data.calVideoSettings = {
|
||||
create: {
|
||||
disableRecordingForGuests: calVideoSettings.disableRecordingForGuests ?? false,
|
||||
disableRecordingForOrganizer: calVideoSettings.disableRecordingForOrganizer ?? false,
|
||||
redirectUrlOnExit: calVideoSettings.redirectUrlOnExit ?? null,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (teamId && schedulingType) {
|
||||
const hasMembership = await ctx.prisma.membership.findFirst({
|
||||
where: {
|
||||
|
||||
Reference in new issue
Block a user