Slack Oauth integration - api route ideas

This commit is contained in:
Sean Brydon 2022-03-01 22:37:45 +00:00
parent fd5fd1f9d5
commit 35ffa78e92
12 changed files with 321 additions and 1268 deletions

View File

@ -1,11 +1,13 @@
import * as example from "./_example";
import * as dailyvideo from "./dailyvideo";
import * as slackcalendar from "./slackcalendar";
import * as zoomvideo from "./zoomvideo";
const appStore = {
example,
dailyvideo,
zoomvideo,
slackcalendar,
};
export default appStore;

View File

@ -0,0 +1,32 @@
import { InstallProvider } from "@slack/oauth";
import type { NextApiRequest, NextApiResponse } from "next";
import { stringify } from "querystring";
import { BASE_URL } from "@calcom/lib/constants";
import prisma from "@calcom/prisma";
const client_id = process.env.SLACK_CLIENT_ID;
const client_secret = process.env.SLACK_CLIENT_SECRET;
const scopes = ["incoming-webhook", "commands"];
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method === "GET") {
// Get user
await prisma.user.findFirst({
rejectOnNotFound: true,
where: {
id: req.session?.user?.id,
},
select: {
id: true,
},
});
const params = {
client_id,
scope: scopes.join(","),
};
const query = stringify(params);
const url = `https://slack.com/oauth/v2/authorize?${query}`;
res.status(200).json({ url });
}
}

View File

@ -0,0 +1 @@
export { default as add } from "./add";

View File

@ -0,0 +1,2 @@
// Any commands registered within slack will send an api request to the endpoint
// `/api/integrations/slackcalendar/listeners/action/acitonId`

View File

@ -0,0 +1,2 @@
// Any commands registered within slack will send an api request to the endpoint
// `/api/integrations/slackcalendar/listeners/commands/actionId`

View File

@ -0,0 +1,2 @@
// Any events are triggered within slack slack will send an api request to the endpoint
// `/api/integrations/slackcalendar/listeners/events/actionId`

View File

@ -0,0 +1,2 @@
// Any views that need to display within slack slack will send an api request to the endpoint
// `/api/integrations/slackcalendar/listeners/views/[actionId]`

View File

@ -0,0 +1,25 @@
import type { App } from "@calcom/types/App";
import _package from "./package.json";
export const metadata = {
name: _package.name,
description: _package.description,
installed: true,
category: "video",
imageSrc: "cal-com-icon.svg",
label: "Slack App",
logo: "cal-com-icon.svg",
publisher: "Cal.com",
rating: 5,
reviews: 69,
slug: "slack_calendar",
title: "Slack App",
trending: true,
type: "slack_calendar",
url: "https://cal.com/",
variant: "conferencing",
verified: true,
} as App;
export * as api from "./api";

View File

@ -0,0 +1 @@
// export * from "./constants";

View File

@ -0,0 +1,15 @@
{
"$schema": "https://json.schemastore.org/package.json",
"private": true,
"name": "@calcom/slackcalendar",
"version": "0.0.0",
"main": "./index.ts",
"description": "This is a package for the intergration of slack into the app-store",
"dependencies": {
"@calcom/prisma": "*",
"@slack/oauth": "^2.4.0"
},
"devDependencies": {
"@calcom/types": "*"
}
}

View File

@ -0,0 +1,6 @@
<svg width="56" height="56" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="56" height="56" rx="12" fill="#292929" />
<path
d="M18.628 36.781c2.846 0 4.946-1.096 6.183-2.59l-2.38-2.03c-.957 1.05-2.147 1.587-3.733 1.587-3.22 0-5.204-2.427-5.204-5.413 0-2.987 1.984-5.46 5.134-5.46 1.47 0 2.683.513 3.663 1.54l2.31-2.007c-1.47-1.75-3.313-2.567-5.973-2.567-5.04 0-8.517 3.803-8.517 8.493 0 4.667 3.663 8.447 8.517 8.447ZM31.69 36.781c2.17 0 3.267-.91 3.92-2.286v1.983h3.057V24.344H35.54v1.914c-.653-1.307-1.75-2.17-3.85-2.17-3.337 0-5.997 2.87-5.997 6.37s2.66 6.323 5.997 6.323Zm-2.847-6.346c0-1.89 1.354-3.5 3.36-3.5 2.077 0 3.407 1.633 3.407 3.523 0 1.89-1.33 3.477-3.407 3.477-2.006 0-3.36-1.657-3.36-3.5ZM41.472 36.478h3.15V19.444h-3.15v17.034Z"
fill="#fff" />
</svg>

After

Width:  |  Height:  |  Size: 806 B

1499
yarn.lock

File diff suppressed because it is too large Load Diff