Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
chore: Remove free use of Cal.AI (calcom#12489)
Browse files Browse the repository at this point in the history
  • Loading branch information
exception authored Nov 23, 2023
1 parent 0910f65 commit 9903fca
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 59 deletions.
2 changes: 0 additions & 2 deletions packages/app-store/cal-ai/DESCRIPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ items:
- 5.jpg
---

**FREE TRIAL until December 1st, 2023**

{DESCRIPTION}

## Example questions:
Expand Down
43 changes: 0 additions & 43 deletions packages/app-store/cal-ai/api/_getAdd.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,14 @@
import type { NextApiRequest, NextApiResponse } from "next";

import { defaultResponder } from "@calcom/lib/server";
import { createContext } from "@calcom/trpc/server/createContext";
import { apiKeysRouter } from "@calcom/trpc/server/routers/viewer/apiKeys/_router";

import checkSession from "../../_utils/auth";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
import { checkInstalled, createDefaultInstallation } from "../../_utils/installation";
import { withPaidAppRedirect } from "../../_utils/paid-apps";
import appConfig from "../config.json";

const trialEndDate = new Date(Date.UTC(2023, 11, 1));

export async function getHandler(req: NextApiRequest, res: NextApiResponse) {
const session = checkSession(req);

// if date is in the future, we install normally.
if (new Date() < trialEndDate) {
const ctx = await createContext({ req, res });
const caller = apiKeysRouter.createCaller(ctx);

const apiKey = await caller.create({
note: "Cal.ai",
expiresAt: null,
appId: "cal-ai",
});

await checkInstalled(appConfig.slug, session.user.id);
await createDefaultInstallation({
appType: appConfig.type,
userId: session.user.id,
slug: appConfig.slug,
key: {
apiKey,
},
});

await fetch(
`${process.env.NODE_ENV === "development" ? "http://localhost:3005" : "https://cal.ai"}/api/onboard`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
userId: session.user.id,
}),
}
);

return { url: getInstalledAppPath({ variant: appConfig.variant, slug: "cal-ai" }) };
}

const redirectUrl = await withPaidAppRedirect({
appPaidMode: appConfig.paid.mode,
appSlug: appConfig.slug,
Expand Down
Loading

0 comments on commit 9903fca

Please sign in to comment.