Files
calendar/packages/app-store/jelly/lib/VideoApiAdapter.ts
T
3a4f944aac feat: jelly integration (#13929)
* v1

* don't need to search DB for user

* return early if no user

* use one deleteMany to ensure only 1 credential

* rm expiration

* fix API request

* proper type

* Update packages/app-store/jelly/lib/VideoApiAdapter.ts

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>

* Update packages/app-store/jelly/lib/VideoApiAdapter.ts

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>

* Update packages/app-store/jelly/lib/VideoApiAdapter.ts

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>

* Update packages/app-store/jelly/api/callback.ts

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>

* Fix callback URL

---------

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com>
2024-03-01 16:45:41 +00:00

53 lines
1.8 KiB
TypeScript

import type { CalendarEvent, EventBusyDate } from "@calcom/types/Calendar";
import type { CredentialPayload } from "@calcom/types/Credential";
import type { PartialReference } from "@calcom/types/EventManager";
import type { VideoApiAdapter, VideoCallData } from "@calcom/types/VideoApiAdapter";
type JellyToken = {
access_token: string;
};
const JellyVideoApiAdapter = (credential: CredentialPayload): VideoApiAdapter => {
return {
createMeeting: async (event: CalendarEvent): Promise<VideoCallData> => {
// get keys from slug
const keys = credential.key as JellyToken;
const { access_token } = keys;
// create jelly link
const jellyLink = await fetch("https://www.jellyjelly.com/api/ti/start_jelly", {
method: "POST",
headers: {
Authorization: `Bearer ${access_token}`,
"Content-Type": "application/json",
},
});
const jellyLinkData = await jellyLink.json();
return {
type: "jelly_conferencing",
id: jellyLinkData.talkId,
password: "",
url: jellyLinkData.url,
};
},
updateMeeting: async (bookingRef: PartialReference, event: CalendarEvent): Promise<VideoCallData> => {
// don't update jelly link
return {
type: "jelly_conferencing",
id: bookingRef.externalCalendarId ? bookingRef.externalCalendarId : "",
password: "",
url: bookingRef.meetingUrl ? bookingRef.meetingUrl : "",
};
},
deleteMeeting: async (uid: string): Promise<unknown> => {
// delete jelly link
return {};
},
getAvailability: async (dateFrom?: string, dateTo?: string): Promise<EventBusyDate[]> => {
// get jelly availability
return [];
},
};
};
export default JellyVideoApiAdapter;