diff --git a/packages/app-store/slackmessaging/_metadata.ts b/packages/app-store/slackmessaging/_metadata.ts index e6df330491..e4fc5307e6 100644 --- a/packages/app-store/slackmessaging/_metadata.ts +++ b/packages/app-store/slackmessaging/_metadata.ts @@ -5,11 +5,6 @@ import _package from "./package.json"; export const metadata = { name: "Slack App", description: _package.description, - installed: !!( - process.env.SLACK_CLIENT_ID && - process.env.SLACK_CLIENT_SECRET && - process.env.SLACK_SIGNING_SECRET - ), category: "messaging", imageSrc: "/apps/slack.svg", logo: "/apps/slack.svg", diff --git a/packages/app-store/slackmessaging/api/callback.ts b/packages/app-store/slackmessaging/api/callback.ts index 20541a0ff1..ee2f37189f 100644 --- a/packages/app-store/slackmessaging/api/callback.ts +++ b/packages/app-store/slackmessaging/api/callback.ts @@ -3,8 +3,10 @@ import { stringify } from "querystring"; import prisma from "@calcom/prisma"; -const client_id = process.env.SLACK_CLIENT_ID; -const client_secret = process.env.SLACK_CLIENT_SECRET; +import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug"; + +let client_id = ""; +let client_secret = ""; export default async function handler(req: NextApiRequest, res: NextApiResponse) { if (!req.session?.user?.id) { @@ -19,6 +21,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) res.redirect("/apps/installed"); // Redirect to where the user was if they cancel the signup or if the oauth fails } + const appKeys = await getAppKeysFromSlug("slack"); + if (typeof appKeys.client_id === "string") client_id = appKeys.client_id; + if (typeof appKeys.client_secret === "string") client_secret = appKeys.client_secret; + if (!client_id) return res.status(400).json({ message: "Slack client_id missing" }); + if (!client_secret) return res.status(400).json({ message: "Slack client_secret missing" }); + const query = { client_secret, client_id,