Fix/fallback to calvideo (#4992)

* try/catch on createMeeting zoom

* add handle response body from zoom

* db invalid credential flag

* Update VideoApiAdapter.ts

* Added notes and try/catches

* Remove double response error validation

* Fallback to calvideo

* Fix types for credentials

* Add nullable to invalid field from credential table

* Fix calendar service credential creation with bad type

* revert db migration invalid on credential table

* Revert "Fix types for credentials"

This reverts commit 1623305aea23a33c39ba7b6fb5604dd71c6205d7.

* Revert "Fix calendar service credential creation with bad type"

This reverts commit 3fd3b08f2ee6c7019428a8ff454d371e23759ad7.

* Remove migration

* Fix for property name for api key on dailyvideo

* remove unused prop from credential

* Revert "Fix for property name for api key on dailyvideo"

This reverts commit 32976934e05e6923210718ccd5634c1357828f65.

* Tests fixes

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: zomars <[email protected]>
This commit is contained in:
authored and GitHub committed 2022-10-14 02:36:43 +00:00
1 parent 74a16e28f4
commit 1c165bd934
2 files changed
+99 -52

No files matched your search

+36 -11
View File
@@ -3,6 +3,7 @@ import short from "short-uuid";
import { v5 as uuidv5 } from "uuid";
import appStore from "@calcom/app-store";
import { getDailyAppKeys } from "@calcom/app-store/dailyvideo/lib/getDailyAppKeys";
import { sendBrokenIntegrationEmail } from "@calcom/emails";
import { getUid } from "@calcom/lib/CalEventParser";
import logger from "@calcom/lib/logger";
@@ -44,18 +45,28 @@ const createMeeting = async (credential: Credential, calEvent: CalendarEvent) =>
const videoAdapters = getVideoAdapters([credential]);
const [firstVideoAdapter] = videoAdapters;
const createdMeeting = await firstVideoAdapter?.createMeeting(calEvent).catch(async (e) => {
await sendBrokenIntegrationEmail(calEvent, "video");
console.error("createMeeting failed", e, calEvent);
});
let createdMeeting;
try {
createdMeeting = await firstVideoAdapter?.createMeeting(calEvent);
if (!createdMeeting) {
return {
type: credential.type,
success: false,
uid,
originalEvent: calEvent,
};
if (!createdMeeting) {
return {
type: credential.type,
success: false,
uid,
originalEvent: calEvent,
};
}
} catch (err) {
await sendBrokenIntegrationEmail(calEvent, "video");
console.error("createMeeting failed", err, calEvent);
// Default to calVideo
const defaultMeeting = await createMeetingWithCalVideo(calEvent);
if (defaultMeeting) {
createdMeeting = defaultMeeting;
calEvent.location = "integrations:dailyvideo";
}
}
return {
@@ -117,4 +128,18 @@ const deleteMeeting = (credential: Credential, uid: string): Promise<unknown> =>
return Promise.resolve({});
};
// @TODO: This is a temporary solution to create a meeting with cal.com video as fallback url
const createMeetingWithCalVideo = async (calEvent: CalendarEvent) => {
const [videoAdapter] = getVideoAdapters([
{
id: 0,
appId: "daily-video",
type: "daily_video",
userId: null,
key: await getDailyAppKeys(),
},
]);
return videoAdapter?.createMeeting(calEvent);
};
export { getBusyVideoTimes, createMeeting, updateMeeting, deleteMeeting };