fix: Default to Daily if Viable (#10279)

* Default to daily if viable

* Add Zod schema parsing
This commit is contained in:
Joe Au-Yeung authored and GitHub committed 2023-07-20 12:57:10 -04:00
1 parent 3c57082fa6
commit 66c1e29d91
2 files changed
+17 -3

No files matched your search

@@ -297,8 +297,6 @@ async function runTestStepsCommonForTeamAndUserEventType(
},
});
expect(payload.location).toBe("integrations:daily");
expect(payload.attendees[0]).toMatchObject({
name: "Booker",
email: "booker@example.com",
+17 -1
View File
@@ -5,6 +5,7 @@ import type { z } from "zod";
import { getCalendar } from "@calcom/app-store/_utils/getCalendar";
import { FAKE_DAILY_CREDENTIAL } from "@calcom/app-store/dailyvideo/lib/VideoApiAdapter";
import { appKeysSchema as calVideoKeysSchema } from "@calcom/app-store/dailyvideo/zod";
import { getEventLocationTypeFromApp } from "@calcom/app-store/locations";
import { MeetLocationType } from "@calcom/app-store/locations";
import getApps from "@calcom/app-store/utils";
@@ -94,7 +95,22 @@ export default class EventManager {
public async create(event: CalendarEvent): Promise<CreateUpdateResult> {
const evt = processLocation(event);
// Fallback to cal video if no location is set
if (!evt.location) evt["location"] = "integrations:daily";
if (!evt.location) {
// See if cal video is enabled & has keys
const calVideo = await prisma.app.findFirst({
where: {
slug: "daily-video",
},
select: {
keys: true,
enabled: true,
},
});
const calVideoKeys = calVideoKeysSchema.safeParse(calVideo?.keys);
if (calVideo?.enabled && calVideoKeys.success) evt["location"] = "integrations:daily";
}
// Fallback to Cal Video if Google Meet is selected w/o a Google Cal
if (evt.location === MeetLocationType && evt.destinationCalendar?.integration !== "google_calendar") {