Add Huddle01 integration (#1675)

* Add Huddle01 integration

* updated huddle01 locale strings

Co-authored-by: deepso <deeps.o7o8.y@gmail.com>
Co-authored-by: Bailey Pumfleet <pumfleet@hey.com>
This commit is contained in:
authored and GitHub committed 2022-02-03 11:59:02 +00:00
1 parent acf8b83b1a
commit 64db8d1cd4
24 files changed
+142 -6

No files matched your search

+9 -2
View File
@@ -4,6 +4,7 @@ import merge from "lodash/merge";
import { v5 as uuidv5 } from "uuid";
import { FAKE_DAILY_CREDENTIAL } from "@lib/integrations/Daily/DailyVideoApiAdapter";
import { FAKE_HUDDLE_CREDENTIAL } from "@lib/integrations/Huddle01/Huddle01VideoApiAdapter";
import { createEvent, updateEvent } from "@lib/integrations/calendar/CalendarManager";
import { AdditionInformation, CalendarEvent } from "@lib/integrations/calendar/interfaces/Calendar";
import { LocationType } from "@lib/location";
@@ -48,15 +49,20 @@ export const isDaily = (location: string): boolean => {
return location === "integrations:daily";
};
export const isHuddle01 = (location: string): boolean => {
return location === "integrations:huddle01";
};
export const isDedicatedIntegration = (location: string): boolean => {
return isZoom(location) || isDaily(location);
return isZoom(location) || isDaily(location) || isHuddle01(location);
};
export const getLocationRequestFromIntegration = (location: string) => {
if (
location === LocationType.GoogleMeet.valueOf() ||
location === LocationType.Zoom.valueOf() ||
location === LocationType.Daily.valueOf()
location === LocationType.Daily.valueOf() ||
location === LocationType.Huddle01.valueOf()
) {
const requestId = uuidv5(location, uuidv5.URL);
@@ -108,6 +114,7 @@ export default class EventManager {
if (hasDailyIntegration) {
this.videoCredentials.push(FAKE_DAILY_CREDENTIAL);
}
this.videoCredentials.push(FAKE_HUDDLE_CREDENTIAL);
}
/**
+2
View File
@@ -14,6 +14,8 @@ export function getIntegrationName(name: string) {
return "Apple Calendar";
case "daily_video":
return "Daily";
case "huddle01_video":
return "Huddle01";
}
}
@@ -0,0 +1,48 @@
import { Credential } from "@prisma/client";
import { handleErrorsJson } from "@lib/errors";
import { PartialReference } from "@lib/events/EventManager";
import { randomString } from "@lib/random";
import { VideoApiAdapter, VideoCallData } from "@lib/videoClient";
export const FAKE_HUDDLE_CREDENTIAL: Credential = {
id: +new Date().getTime(),
type: "huddle01_video",
key: { apikey: randomString(12) },
userId: +new Date().getTime(),
};
const Huddle01VideoApiAdapter = (): VideoApiAdapter => {
return {
getAvailability: () => {
return Promise.resolve([]);
},
createMeeting: async (): Promise<VideoCallData> => {
const res = await fetch(
"https://wpss2zlpb9.execute-api.us-east-1.amazonaws.com/new-meeting?utmCampaign=cal.com&utmSource=partner&utmMedium=calendar"
);
const { url } = await handleErrorsJson(res);
return Promise.resolve({
type: "huddle01_video",
id: randomString(21),
password: "",
url,
});
},
deleteMeeting: async (): Promise<void> => {
Promise.resolve();
},
updateMeeting: (bookingRef: PartialReference): Promise<VideoCallData> => {
return Promise.resolve({
type: "huddle01_video",
id: bookingRef.meetingId as string,
password: bookingRef.meetingPassword as string,
url: bookingRef.meetingUrl as string,
});
},
};
};
export default Huddle01VideoApiAdapter;
+13 -1
View File
@@ -23,6 +23,7 @@ export type Integration = {
| "caldav_calendar"
| "apple_calendar"
| "stripe_payment"
| "huddle01_video"
| "metamask_web3";
title: string;
imageSrc: string;
@@ -63,6 +64,14 @@ export const ALL_INTEGRATIONS = [
description: "Video Conferencing",
variant: "conferencing",
},
{
installed: true,
type: "huddle01_video",
title: "Huddle01",
imageSrc: "integrations/huddle.svg",
description: "Video Conferencing",
variant: "conferencing",
},
{
installed: true,
type: "caldav_calendar",
@@ -125,7 +134,10 @@ export type IntegrationMeta = ReturnType<typeof getIntegrations>;
export function hasIntegration(integrations: IntegrationMeta, type: string): boolean {
return !!integrations.find(
(i) => i.type === type && !!i.installed && (type === "daily_video" || i.credentials.length > 0)
(i) =>
i.type === type &&
!!i.installed &&
(type === "daily_video" || type === "huddle01_video" || i.credentials.length > 0)
);
}
export function hasIntegrationInstalled(type: Integration["type"]): boolean {
+1
View File
@@ -4,4 +4,5 @@ export enum LocationType {
GoogleMeet = "integrations:google:meet",
Zoom = "integrations:zoom",
Daily = "integrations:daily",
Huddle01 = "integrations:huddle01",
}
+4
View File
@@ -5,6 +5,7 @@ import { v5 as uuidv5 } from "uuid";
import { getUid } from "@lib/CalEventParser";
import { EventResult } from "@lib/events/EventManager";
import { PartialReference } from "@lib/events/EventManager";
import Huddle01VideoApiAdapter from "@lib/integrations/Huddle01/Huddle01VideoApiAdapter";
import logger from "@lib/logger";
import DailyVideoApiAdapter from "./integrations/Daily/DailyVideoApiAdapter";
@@ -44,6 +45,9 @@ const getVideoAdapters = (withCredentials: Credential[]): VideoApiAdapter[] =>
case "daily_video":
acc.push(DailyVideoApiAdapter(cred));
break;
case "huddle01_video":
acc.push(Huddle01VideoApiAdapter());
break;
default:
break;
}