-
Notifications
You must be signed in to change notification settings - Fork 12k
feat: jelly integration #13929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: jelly integration #13929
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
907f705
v1
diogeneshamilton 0c5a757
don't need to search DB for user
diogeneshamilton 2478870
return early if no user
diogeneshamilton 6252542
use one deleteMany to ensure only 1 credential
diogeneshamilton a2255c7
rm expiration
diogeneshamilton 71a7891
fix API request
diogeneshamilton 87c9a3b
proper type
diogeneshamilton ca905ea
Update packages/app-store/jelly/lib/VideoApiAdapter.ts
diogeneshamilton b3738a3
Update packages/app-store/jelly/lib/VideoApiAdapter.ts
diogeneshamilton bfb6632
Update packages/app-store/jelly/lib/VideoApiAdapter.ts
diogeneshamilton 538d869
Update packages/app-store/jelly/api/callback.ts
diogeneshamilton 1e86824
Merge branch 'main' into jelly-integration
joeauyeung b3be520
Fix callback URL
joeauyeung 0c32931
Merge branch 'main' into jelly-integration
joeauyeung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| items: | ||
| - 1.jpeg | ||
| - 2.jpeg | ||
| - 3.jpeg | ||
| --- | ||
|
|
||
| {DESCRIPTION} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import type { NextApiRequest } from "next"; | ||
| import { stringify } from "querystring"; | ||
| import { z } from "zod"; | ||
|
|
||
| import { WEBAPP_URL } from "@calcom/lib/constants"; | ||
| import { defaultHandler, defaultResponder } from "@calcom/lib/server"; | ||
|
|
||
| import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug"; | ||
| import { encodeOAuthState } from "../../_utils/oauth/encodeOAuthState"; | ||
|
|
||
| const jellyAppKeysSchema = z.object({ | ||
| client_id: z.string(), | ||
| client_secret: z.string(), | ||
| }); | ||
|
|
||
| export const getJellyAppKeys = async () => { | ||
| const appKeys = await getAppKeysFromSlug("jelly"); | ||
| return jellyAppKeysSchema.parse(appKeys); | ||
| }; | ||
|
|
||
| async function handler(req: NextApiRequest) { | ||
| // Get user | ||
| const user = req?.session?.user; | ||
| if (!user) { | ||
| return { status: 401, body: { error: "Unauthorized" } }; | ||
| } | ||
|
|
||
| const { client_id } = await getJellyAppKeys(); | ||
| const state = encodeOAuthState(req); | ||
|
|
||
| const params = { | ||
| response_type: "code", | ||
| app_id: client_id, | ||
| redirect_uri: `${WEBAPP_URL}/api/integrations/jelly/callback`, | ||
| state, | ||
| scope: "write:jellies,read:user_email_phone", | ||
| }; | ||
| const query = stringify(params); | ||
| const url = `https://jellyjelly.com/login/oauth?${query}`; | ||
| return { url }; | ||
| } | ||
|
|
||
| export default defaultHandler({ | ||
| GET: Promise.resolve({ default: defaultResponder(handler) }), | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import type { NextApiRequest, NextApiResponse } from "next"; | ||
|
|
||
| import prisma from "@calcom/prisma"; | ||
|
|
||
| import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug"; | ||
| import getInstalledAppPath from "../../_utils/getInstalledAppPath"; | ||
| import createOAuthAppCredential from "../../_utils/oauth/createOAuthAppCredential"; | ||
|
|
||
| export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
| const userId = req.session?.user.id; | ||
| if (!userId) { | ||
| return res.status(404).json({ message: "No user found" }); | ||
| } | ||
| const { code } = req.query; | ||
| const { client_id, client_secret } = await getAppKeysFromSlug("jelly"); | ||
|
|
||
| const result = await fetch(`https://www.jellyjelly.com/login/oauth/access_token`, { | ||
| method: "POST", | ||
| body: JSON.stringify({ code, client_id, client_secret }), | ||
| }); | ||
|
|
||
| if (result.status !== 200) { | ||
| let errorMessage = "Something is wrong with the Jelly API"; | ||
| try { | ||
| const responseBody = await result.json(); | ||
| errorMessage = responseBody.error; | ||
| } catch (e) {} | ||
|
|
||
| res.status(400).json({ message: errorMessage }); | ||
| return; | ||
| } | ||
|
|
||
| const responseBody = await result.json(); | ||
| if (responseBody.error) { | ||
| res.status(400).json({ message: responseBody.error }); | ||
| return; | ||
| } | ||
|
|
||
| /** | ||
| * With this we take care of no duplicate jelly key for a single user | ||
| * when creating a room using deleteMany if there is already a jelly key | ||
| * */ | ||
| await prisma.credential.deleteMany({ | ||
| where: { | ||
| type: "jelly_conferencing", | ||
| userId, | ||
| appId: "jelly", | ||
| }, | ||
| }); | ||
|
|
||
| await createOAuthAppCredential( | ||
| { appId: "jelly", type: "jelly_conferencing" }, | ||
| { access_token: responseBody.access_token }, | ||
| req | ||
| ); | ||
|
|
||
| res.redirect(getInstalledAppPath({ variant: "conferencing", slug: "jelly" })); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export { default as add } from "./add"; | ||
| export { default as callback } from "./callback"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "/*": "Don't modify slug - If required, do it using cli edit command", | ||
| "name": "Jelly", | ||
| "slug": "jelly", | ||
| "type": "jelly_conferencing", | ||
| "logo": "icon.svg", | ||
| "url": "https://jellyjelly.com", | ||
| "variant": "conferencing", | ||
| "categories": ["conferencing"], | ||
| "publisher": "Jelly", | ||
| "email": "support@jellyjelly.com", | ||
| "appData": { | ||
| "location": { | ||
| "type": "integrations:{SLUG}_video", | ||
| "label": "{TITLE}", | ||
| "linkType": "dynamic" | ||
| } | ||
| }, | ||
| "description": "Jelly is a camera-free voice chat platform. No frills, no makeup needed, just good talking. Our AI magic handles the rest by highlighting and publishing key moments with rich visuals.", | ||
| "isTemplate": false, | ||
| "__createdUsingCli": true, | ||
| "__template": "event-type-location-video-static" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export * as api from "./api"; | ||
| export * as lib from "./lib"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { default as VideoApiAdapter } from "./VideoApiAdapter"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "private": true, | ||
| "name": "@calcom/jelly", | ||
| "version": "0.0.0", | ||
| "main": "./index.ts", | ||
| "dependencies": { | ||
| "@calcom/lib": "*" | ||
| }, | ||
| "devDependencies": { | ||
| "@calcom/types": "*" | ||
| }, | ||
| "description": "Jelly is a camera-free voice chat platform. No frills, no makeup needed, just good talking. Our AI magic handles the rest by highlighting and publishing key moments with rich visuals." | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { z } from "zod"; | ||
|
|
||
| export const appDataSchema = z.object({}); | ||
|
|
||
| export const appKeysSchema = z.object({ | ||
| client_id: z.string().min(1), | ||
| client_secret: z.string().min(1), | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.