From d6644bc23223ea8b4531cec72bff4754f2784246 Mon Sep 17 00:00:00 2001 From: Jakob <9266151+chief-nerd@users.noreply.github.com> Date: Thu, 1 Jun 2023 09:48:01 +0200 Subject: [PATCH] feat: Customise JITSI Url path (#8835) * Closes #1847 - adds an environment variable `JITSI_HOST_URL` to configure the Host URL for self hosted instances * Closes #1847 - adds an environment variable `JITSI_HOST_URL` to configure the Host URL for self hosted instances * Closes #1847 - adds an environment variable `JITSI_HOST_URL` to configure the Host URL for self hosted instances * Replace Tab with spaces * Add JITSI_HOST_URL env * Remote Tabs for Spaces * Support jitsi_host key * Remove ENV, add Interface jitsi host URL and fallback * Fix linting issues * Clean code * add missing await * Add configurable meeting slug * Refactor to jitsiHost, remove slug generator * zod default doesnt work right now. So remove it * Add replacement values and url encoding * Change Placeholder to unified values. --------- Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Hariom Balhara Co-authored-by: Peer Richelsen --- .../jitsivideo/lib/VideoApiAdapter.ts | 20 ++++++++++++++----- packages/app-store/jitsivideo/zod.ts | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/app-store/jitsivideo/lib/VideoApiAdapter.ts b/packages/app-store/jitsivideo/lib/VideoApiAdapter.ts index 9513e96005..bff005687e 100644 --- a/packages/app-store/jitsivideo/lib/VideoApiAdapter.ts +++ b/packages/app-store/jitsivideo/lib/VideoApiAdapter.ts @@ -1,5 +1,6 @@ import { v4 as uuidv4 } from "uuid"; +import type { CalendarEvent } from "@calcom/types/Calendar"; import type { PartialReference } from "@calcom/types/EventManager"; import type { VideoApiAdapter, VideoCallData } from "@calcom/types/VideoApiAdapter"; @@ -11,19 +12,28 @@ const JitsiVideoApiAdapter = (): VideoApiAdapter => { getAvailability: () => { return Promise.resolve([]); }, - createMeeting: async (): Promise => { + createMeeting: async (eventData: CalendarEvent): Promise => { const appKeys = await getAppKeysFromSlug(metadata.slug); - const meetingID = uuidv4(); + const meetingPattern = (appKeys.jitsiPathPattern as string) || "{uuid}"; + const hostUrl = (appKeys.jitsiHost as string) || "https://meet.jit.si/cal"; - // Default Value - const hostUrl = appKeys.jitsiHost || "https://meet.jit.si/cal"; + //Allows "/{Type}-with-{Attendees}" slug + const meetingID = meetingPattern + .replaceAll("{uuid}", uuidv4()) + .replaceAll("{Title}", eventData.title) + .replaceAll("{Event Type Title}", eventData.type) + .replaceAll("{Scheduler}", eventData.attendees.map((a) => a.name).join("-")) + .replaceAll("{Organizer}", eventData.organizer.name) + .replaceAll("{Location}", eventData.location || "") + .replaceAll("{Team}", eventData.team?.name || "") + .replaceAll(" ", "-"); //Last Rule! - Replace all blanks (%20) with dashes; return Promise.resolve({ type: metadata.type, id: meetingID, password: "", - url: hostUrl + "/" + meetingID, + url: hostUrl + "/" + encodeURIComponent(meetingID), }); }, deleteMeeting: async (): Promise => { diff --git a/packages/app-store/jitsivideo/zod.ts b/packages/app-store/jitsivideo/zod.ts index 825da51594..d39d4f3043 100644 --- a/packages/app-store/jitsivideo/zod.ts +++ b/packages/app-store/jitsivideo/zod.ts @@ -2,6 +2,7 @@ import { z } from "zod"; export const appKeysSchema = z.object({ jitsiHost: z.string().optional(), + jitsiPathPattern: z.string().optional(), }); export const appDataSchema = z.object({});