From 64db8d1cd40c1b627a2159b9db0910eaff0ed79f Mon Sep 17 00:00:00 2001 From: Rohan Gupta <32675945+rohg007@users.noreply.github.com> Date: Thu, 3 Feb 2022 17:29:02 +0530 Subject: [PATCH] Add Huddle01 integration (#1675) * Add Huddle01 integration * updated huddle01 locale strings Co-authored-by: deepso Co-authored-by: Bailey Pumfleet --- components/booking/pages/BookingPage.tsx | 1 + lib/events/EventManager.ts | 11 ++++- lib/integrations.ts | 2 + .../Huddle01/Huddle01VideoApiAdapter.ts | 48 +++++++++++++++++++ lib/integrations/getIntegrations.ts | 14 +++++- lib/location.ts | 1 + lib/videoClient.ts | 4 ++ pages/event-types/[type].tsx | 33 +++++++++++++ pages/integrations/index.tsx | 2 +- public/integrations/huddle.svg | 14 ++++++ public/static/locales/de/common.json | 1 + public/static/locales/en/common.json | 1 + public/static/locales/es/common.json | 1 + public/static/locales/fr/common.json | 1 + public/static/locales/it/common.json | 3 +- public/static/locales/ja/common.json | 1 + public/static/locales/ko/common.json | 1 + public/static/locales/nl/common.json | 1 + public/static/locales/pl/common.json | 1 + public/static/locales/pt-BR/common.json | 1 + public/static/locales/pt/common.json | 1 + public/static/locales/ro/common.json | 3 +- public/static/locales/ru/common.json | 1 + public/static/locales/zh-CN/common.json | 1 + 24 files changed, 142 insertions(+), 6 deletions(-) create mode 100644 lib/integrations/Huddle01/Huddle01VideoApiAdapter.ts create mode 100644 public/integrations/huddle.svg diff --git a/components/booking/pages/BookingPage.tsx b/components/booking/pages/BookingPage.tsx index b34d30a3..ee0aeae9 100644 --- a/components/booking/pages/BookingPage.tsx +++ b/components/booking/pages/BookingPage.tsx @@ -153,6 +153,7 @@ const BookingPage = (props: BookingPageProps) => { [LocationType.GoogleMeet]: "Google Meet", [LocationType.Zoom]: "Zoom Video", [LocationType.Daily]: "Daily.co Video", + [LocationType.Huddle01]: "Huddle01 Video", }; const defaultValues = () => { diff --git a/lib/events/EventManager.ts b/lib/events/EventManager.ts index f1561b0d..379bdcda 100644 --- a/lib/events/EventManager.ts +++ b/lib/events/EventManager.ts @@ -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); } /** diff --git a/lib/integrations.ts b/lib/integrations.ts index 9b317555..3c086197 100644 --- a/lib/integrations.ts +++ b/lib/integrations.ts @@ -14,6 +14,8 @@ export function getIntegrationName(name: string) { return "Apple Calendar"; case "daily_video": return "Daily"; + case "huddle01_video": + return "Huddle01"; } } diff --git a/lib/integrations/Huddle01/Huddle01VideoApiAdapter.ts b/lib/integrations/Huddle01/Huddle01VideoApiAdapter.ts new file mode 100644 index 00000000..7f7893f3 --- /dev/null +++ b/lib/integrations/Huddle01/Huddle01VideoApiAdapter.ts @@ -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 => { + 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 => { + Promise.resolve(); + }, + updateMeeting: (bookingRef: PartialReference): Promise => { + return Promise.resolve({ + type: "huddle01_video", + id: bookingRef.meetingId as string, + password: bookingRef.meetingPassword as string, + url: bookingRef.meetingUrl as string, + }); + }, + }; +}; + +export default Huddle01VideoApiAdapter; diff --git a/lib/integrations/getIntegrations.ts b/lib/integrations/getIntegrations.ts index 266f56c6..24631340 100644 --- a/lib/integrations/getIntegrations.ts +++ b/lib/integrations/getIntegrations.ts @@ -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; 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 { diff --git a/lib/location.ts b/lib/location.ts index 40ed53ce..6f69fab5 100644 --- a/lib/location.ts +++ b/lib/location.ts @@ -4,4 +4,5 @@ export enum LocationType { GoogleMeet = "integrations:google:meet", Zoom = "integrations:zoom", Daily = "integrations:daily", + Huddle01 = "integrations:huddle01", } diff --git a/lib/videoClient.ts b/lib/videoClient.ts index e8869188..4bc2b428 100644 --- a/lib/videoClient.ts +++ b/lib/videoClient.ts @@ -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; } diff --git a/pages/event-types/[type].tsx b/pages/event-types/[type].tsx index 129423d2..cd180048 100644 --- a/pages/event-types/[type].tsx +++ b/pages/event-types/[type].tsx @@ -261,6 +261,8 @@ const EventTypePage = (props: inferSSRProps) => { return

{t("cal_provide_zoom_meeting_url")}

; case LocationType.Daily: return

{t("cal_provide_video_meeting_url")}

; + case LocationType.Huddle01: + return

{t("cal_provide_huddle01_meeting_url")}

; default: return null; } @@ -420,6 +422,34 @@ const EventTypePage = (props: inferSSRProps) => { Google Meet )} + {location.type === LocationType.Huddle01 && ( +
+ + + + + + + Huddle01 Web3 Video +
+ )} {location.type === LocationType.Daily && (
if (hasIntegration(integrations, "daily_video")) { locationOptions.push({ value: LocationType.Daily, label: "Daily.co Video" }); } + if (hasIntegration(integrations, "huddle01_video")) { + locationOptions.push({ value: LocationType.Huddle01, label: "Huddle01 Video" }); + } const currency = (credentials.find((integration) => integration.type === "stripe_payment")?.key as unknown as StripeData) ?.default_currency || "usd"; diff --git a/pages/integrations/index.tsx b/pages/integrations/index.tsx index 6d5218e0..bfab3df7 100644 --- a/pages/integrations/index.tsx +++ b/pages/integrations/index.tsx @@ -480,7 +480,7 @@ function ConnectOrDisconnectIntegrationButton(props: { ); } /** We don't need to "Connect", just show that it's installed */ - if (props.type === "daily_video") { + if (props.type === "daily_video" || props.type === "huddle01_video") { return (

{t("installed")}

diff --git a/public/integrations/huddle.svg b/public/integrations/huddle.svg new file mode 100644 index 00000000..8a9448d4 --- /dev/null +++ b/public/integrations/huddle.svg @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/public/static/locales/de/common.json b/public/static/locales/de/common.json index a33d4cd8..c9d07a5d 100644 --- a/public/static/locales/de/common.json +++ b/public/static/locales/de/common.json @@ -536,6 +536,7 @@ "cal_provide_google_meet_location": "Cal wird einen Google Meet Termin zur Verfügung stellen.", "cal_provide_zoom_meeting_url": "Cal stellt eine Zoom Meeting-URL zur Verfügung.", "cal_provide_video_meeting_url": "Cal stellt eine tägliche Video-Meeting-URL zur Verfügung.", + "cal_provide_huddle01_meeting_url": "Cal stellt eine tägliche Huddle01-Web3-Meeting-URL zur Verfügung.", "require_payment": "Zahlung erforderlich", "commission_per_transaction": "Provision pro Transaktion", "event_type_updated_successfully_description": "Ihr Ereignistyp wurde erfolgreich aktualisiert.", diff --git a/public/static/locales/en/common.json b/public/static/locales/en/common.json index d3714090..67a349ac 100644 --- a/public/static/locales/en/common.json +++ b/public/static/locales/en/common.json @@ -536,6 +536,7 @@ "cal_provide_google_meet_location": "Cal will provide a Google Meet location.", "cal_provide_zoom_meeting_url": "Cal will provide a Zoom meeting URL.", "cal_provide_video_meeting_url": "Cal will provide a Daily video meeting URL.", + "cal_provide_huddle01_meeting_url": "Cal will provide a Huddle01 web3 video meeting URL.", "require_payment": "Require Payment", "commission_per_transaction": "commission per transaction", "event_type_updated_successfully_description": "Your event type has been updated successfully.", diff --git a/public/static/locales/es/common.json b/public/static/locales/es/common.json index 0a7ff763..a1686693 100644 --- a/public/static/locales/es/common.json +++ b/public/static/locales/es/common.json @@ -524,6 +524,7 @@ "cal_provide_google_meet_location": "Cal proporcionará una URL de reunión de Google Meet.", "cal_provide_zoom_meeting_url": "Cal proporcionará una URL de reunión de Zoom.", "cal_provide_video_meeting_url": "Cal proporcionará una URL de reunión de Daily Video.", + "cal_provide_huddle01_meeting_url": "Cal proporcionará una URL de reunión de Huddle01 Web3 Video.", "require_payment": "Requiere Pago", "commission_per_transaction": "Comisión por Transacción", "event_type_updated_successfully_description": "Tu Evento fue Actualizado con Éxito.", diff --git a/public/static/locales/fr/common.json b/public/static/locales/fr/common.json index 812bc278..08b6b5d3 100644 --- a/public/static/locales/fr/common.json +++ b/public/static/locales/fr/common.json @@ -490,6 +490,7 @@ "cal_provide_google_meet_location": "Cal fournira un lien Google Meet.", "cal_provide_zoom_meeting_url": "Cal fournira une URL de réunion Zoom.", "cal_provide_video_meeting_url": "Cal fournira une URL de réunion Daily video.", + "cal_provide_huddle01_meeting_url": "Cal fournira une URL de réunion Huddle01 web3 video.", "require_payment": "Exiger un paiement", "commission_per_transaction": "commission par transaction", "event_type_updated_successfully_description": "Votre type d'événement a été mis à jour avec succès.", diff --git a/public/static/locales/it/common.json b/public/static/locales/it/common.json index 67347057..38a42bcc 100644 --- a/public/static/locales/it/common.json +++ b/public/static/locales/it/common.json @@ -515,7 +515,8 @@ "cal_invitee_phone_number_scheduling": "Cal chiederà al tuo invitato di inserire un numero di telefono prima della pianificazione.", "cal_provide_google_meet_location": "Cal fornirà un Google Meet location.", "cal_provide_zoom_meeting_url": "Cal fornirà un URL di riunione Zoom.", - "cal_provide_video_meeting_url": "Cal fornirà un URL di riunione Zoom.", + "cal_provide_video_meeting_url": "Cal fornirà un URL di riunione Daily video.", + "cal_provide_huddle01_meeting_url": "Cal fornirà un URL di riunione Huddle01 web3 video.", "require_payment": "Richiedi Pagamento", "commission_per_transaction": "commissione per transazione", "event_type_updated_successfully_description": "Il tuo team è stato aggiornato con successo.", diff --git a/public/static/locales/ja/common.json b/public/static/locales/ja/common.json index ef2d5eda..a6134ab4 100644 --- a/public/static/locales/ja/common.json +++ b/public/static/locales/ja/common.json @@ -488,6 +488,7 @@ "cal_provide_google_meet_location": "CalはGoogleMeetの場所を提供します。", "cal_provide_zoom_meeting_url": "カルはZoomミーティングURLを提供します。", "cal_provide_video_meeting_url": "カルは毎日のビデオミーティングのURLを提供します。", + "cal_provide_huddle01_meeting_url": "カルはHuddle01 Web3ミーティングURLを提供します。", "require_payment": "お支払いが必要です", "commission_per_transaction": "取引あたりの手数料", "event_type_updated_successfully_description": "イベント種別の更新が完了しました。", diff --git a/public/static/locales/ko/common.json b/public/static/locales/ko/common.json index bfc3c572..59958371 100644 --- a/public/static/locales/ko/common.json +++ b/public/static/locales/ko/common.json @@ -511,6 +511,7 @@ "cal_provide_google_meet_location": "Cal은 Google Meet 위치를 제공합니다.", "cal_provide_zoom_meeting_url": "Cal은 Zoom 회의 URL을 제공합니다.", "cal_provide_video_meeting_url": "Cal은 일일 화상 회의 URL을 제공합니다.", + "cal_provide_huddle01_meeting_url": "Cal은 Huddle01 Web3 회의 URL을 제공합니다.", "require_payment": "지불 요청", "commission_per_transaction": "거래당 수수료", "event_type_updated_successfully_description": "이벤트 타입이 성공적으로 업데이트되었습니다.", diff --git a/public/static/locales/nl/common.json b/public/static/locales/nl/common.json index 29b4b3d6..ab0c047c 100644 --- a/public/static/locales/nl/common.json +++ b/public/static/locales/nl/common.json @@ -481,6 +481,7 @@ "cal_provide_google_meet_location": "Cal zal een Google Meet meeting-URL meegeven in de afspraak bevestiging.", "cal_provide_zoom_meeting_url": "Cal zal een Zoom meeting-URL meegeven in de afspraak bevestiging.", "cal_provide_video_meeting_url": "Cal zal een Daily meeting-URL meegeven in de afspraak bevestiging.", + "cal_provide_huddle01_meeting_url": "Cal zal een Huddle01 web3 meeting-URL meegeven in de afspraak bevestiging.", "require_payment": "Betaling vereisen", "commission_per_transaction": "commissie per transactie", "event_type_updated_successfully_description": "Uw evenement is met succes bijgewerkt.", diff --git a/public/static/locales/pl/common.json b/public/static/locales/pl/common.json index 0724a665..57a0d831 100644 --- a/public/static/locales/pl/common.json +++ b/public/static/locales/pl/common.json @@ -527,6 +527,7 @@ "cal_provide_google_meet_location": "Cal zapewni lokalizację Google Meet.", "cal_provide_zoom_meeting_url": "Cal zapewni URL spotkania Zoom.", "cal_provide_video_meeting_url": "Kal poda adres URL spotkania wideo platformy Daily.", + "cal_provide_huddle01_meeting_url": "Cal zapewni URL spotkania Huddle01 Web3.", "require_payment": "Wymagaj płatności", "commission_per_transaction": "prowizja za transakcję", "event_type_updated_successfully_description": "Twój typ wydarzenia został pomyślnie zaktualizowany.", diff --git a/public/static/locales/pt-BR/common.json b/public/static/locales/pt-BR/common.json index 33e41767..867be77c 100644 --- a/public/static/locales/pt-BR/common.json +++ b/public/static/locales/pt-BR/common.json @@ -527,6 +527,7 @@ "cal_provide_google_meet_location": "Cal fornecerá um link para o Google Meet.", "cal_provide_zoom_meeting_url": "Cal fornecerá uma URL de reunião do Zoom.", "cal_provide_video_meeting_url": "O Cal irá fornecer um URL de reunião do Daily video.", + "cal_provide_huddle01_meeting_url": "O Cal irá fornecer um URL de reunião do Huddle01 Web3 video.", "require_payment": "Requerer Pagamento", "commission_per_transaction": "comissão por transação", "event_type_updated_successfully_description": "O seu tipo de evento foi atualizado com sucesso.", diff --git a/public/static/locales/pt/common.json b/public/static/locales/pt/common.json index 06d5ba0f..9a14da74 100644 --- a/public/static/locales/pt/common.json +++ b/public/static/locales/pt/common.json @@ -536,6 +536,7 @@ "cal_provide_google_meet_location": "Cal fornecerá um local para o Google Meet.", "cal_provide_zoom_meeting_url": "Cal fornecerá uma URL de reunião Zoom .", "cal_provide_video_meeting_url": "O Cal irá fornecer um URL de reunião do Daily video.", + "cal_provide_huddle01_meeting_url": "O Cal irá fornecer um URL de reunião do Huddle01 Web3 video.", "require_payment": "Requer Pagamento", "commission_per_transaction": "comissão por transação", "event_type_updated_successfully_description": "O seu tipo de evento foi atualizado com sucesso.", diff --git a/public/static/locales/ro/common.json b/public/static/locales/ro/common.json index 3895cfaf..ab0873b7 100644 --- a/public/static/locales/ro/common.json +++ b/public/static/locales/ro/common.json @@ -487,7 +487,8 @@ "cal_invitee_phone_number_scheduling": "Cal va cere invitatului dvs. să introducă un număr de telefon înainte de programare.", "cal_provide_google_meet_location": "Cal va oferi o locație Google Meet.", "cal_provide_zoom_meeting_url": "Cal va oferi un URL pentru ședința de Zoom.", - "cal_provide_video_meeting_url": "Cal va oferi un URL pentru ședința de Zoom.", + "cal_provide_video_meeting_url": "Cal va oferi un URL pentru ședința de Daily.", + "cal_provide_huddle01_meeting_url": "Cal va oferi un URL pentru ședința de Huddle01 Web3.", "require_payment": "Solicită plata", "commission_per_transaction": "comision per tranzacție", "event_type_updated_successfully_description": "Tipul de eveniment a fost actualizat cu succes.", diff --git a/public/static/locales/ru/common.json b/public/static/locales/ru/common.json index a0bd115c..7d53432e 100644 --- a/public/static/locales/ru/common.json +++ b/public/static/locales/ru/common.json @@ -528,6 +528,7 @@ "cal_provide_google_meet_location": "Cal создаст ссылку на встречу в Google Meet.", "cal_provide_zoom_meeting_url": "Cal создаст ссылку на встречу в Zoom.", "cal_provide_video_meeting_url": "Cal создаст ссылку на встречу в Daily.", + "cal_provide_huddle01_meeting_url": "Cal создаст ссылку на встречу в Huddle01 Web3.", "require_payment": "Требуется оплата", "commission_per_transaction": "комиссия за сделку", "event_type_updated_successfully_description": "Ваш шаблон события успешно обновлён.", diff --git a/public/static/locales/zh-CN/common.json b/public/static/locales/zh-CN/common.json index dea4b32b..b64af2f7 100644 --- a/public/static/locales/zh-CN/common.json +++ b/public/static/locales/zh-CN/common.json @@ -534,6 +534,7 @@ "cal_provide_google_meet_location": "Cal 将提供 Google Meet 位置。", "cal_provide_zoom_meeting_url": "Cal 将提供Zoom会议 URL", "cal_provide_video_meeting_url": "Cal 将提供Daily视频会议 URL", + "cal_provide_huddle01_meeting_url": "Cal 将提供Huddle01 Web3视频会议 URL", "require_payment": "需要付款", "commission_per_transaction": "每笔交易的佣金", "event_type_updated_successfully_description": "您的事件类型更新成功。",