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
@@ -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