From 879619e07513577f1aa2b1a82779f7b499fb31fd Mon Sep 17 00:00:00 2001 From: zomars Date: Sat, 4 Jun 2022 11:23:56 -0600 Subject: [PATCH] Fallbacks to Cal Video when missing credentials for location --- packages/core/EventManager.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/core/EventManager.ts b/packages/core/EventManager.ts index 9f0c89fc7d..45e9dcaa67 100644 --- a/packages/core/EventManager.ts +++ b/packages/core/EventManager.ts @@ -3,6 +3,7 @@ import async from "async"; import merge from "lodash/merge"; import { v5 as uuidv5 } from "uuid"; +import { FAKE_DAILY_CREDENTIAL } from "@calcom/app-store/dailyvideo/lib/VideoApiAdapter"; import getApps from "@calcom/app-store/utils"; import prisma from "@calcom/prisma"; import type { AdditionInformation, CalendarEvent } from "@calcom/types/Calendar"; @@ -319,8 +320,17 @@ export default class EventManager { /** @fixme potential bug since Google Meet are saved as `integrations:google:meet` and there are no `google:meet` type in our DB */ const integrationName = event.location.replace("integrations:", ""); + let videoCredential = this.videoCredentials.find((credential: Credential) => + credential.type.includes(integrationName) + ); - return this.videoCredentials.find((credential: Credential) => credential.type.includes(integrationName)); + /** + * This might happen if someone tries to use a location with a missing credential, so we fallback to Cal Video. + * @todo remove location from event types that has missing credentials + * */ + if (!videoCredential) videoCredential = FAKE_DAILY_CREDENTIAL; + + return videoCredential; } /**