Skip to content

Commit acf2a56

Browse files
committed
update slack
Signed-off-by: Innei <tukon479@gmail.com>
1 parent 0c7834d commit acf2a56

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

.vscode/settings.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"editor.defaultFormatter": "Prisma.prisma"
1212
},
1313
"[typescript]": {
14-
"editor.defaultFormatter": "biomejs.biome"
14+
"editor.defaultFormatter": "vscode.typescript-language-features"
1515
},
1616
"[typescriptreact]": {
1717
"editor.defaultFormatter": "biomejs.biome"
@@ -21,13 +21,19 @@
2121
},
2222
"editor.formatOnSave": true,
2323
"tailwindCSS.experimental.classRegex": [
24-
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
25-
["cx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]
24+
[
25+
"cva\\(([^)]*)\\)",
26+
"[\"'`]([^\"'`]*).*?[\"'`]"
27+
],
28+
[
29+
"cx\\(([^)]*)\\)",
30+
"(?:'|\"|`)([^']*)(?:'|\"|`)"
31+
]
2632
],
2733
"typescript.enablePromptUseWorkspaceTsdk": true,
2834
"typescript.tsdk": "node_modules/typescript/lib",
2935
"typescript.preferences.autoImportFileExcludePatterns": [
3036
"next/router.d.ts",
3137
"next/dist/client/router.d.ts"
3238
]
33-
}
39+
}

apps/api/src/controllers/webhook.controller.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import path from 'node:path';
33
import type { WebhookEvent } from '@clerk/fastify';
44
import { AccessLevel, db } from '@openpanel/db';
55
import {
6+
createSlackInstaller,
67
sendSlackNotification,
7-
slackInstaller,
8+
89
} from '@openpanel/integrations/src/slack';
910
import { getRedisPub } from '@openpanel/redis';
1011
import { zSlackAuthResponse } from '@openpanel/validation';
@@ -184,6 +185,7 @@ export async function slackWebhook(
184185
request.log.error(parsedParams.error, 'Invalid params');
185186
return reply.status(400).send({ error: 'Invalid params' });
186187
}
188+
const slackInstaller = createSlackInstaller();
187189

188190
const veryfiedState = await slackInstaller.stateStore?.verifyStateParam(
189191
new Date(),

packages/integrations/src/slack.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,27 @@
33
import { LogLevel, App as SlackApp } from '@slack/bolt';
44
import { InstallProvider } from '@slack/oauth';
55

6-
const SLACK_CLIENT_ID = process.env.SLACK_CLIENT_ID;
7-
const SLACK_CLIENT_SECRET = process.env.SLACK_CLIENT_SECRET;
86
const SLACK_OAUTH_REDIRECT_URL = process.env.SLACK_OAUTH_REDIRECT_URL;
9-
const SLACK_STATE_SECRET = process.env.SLACK_STATE_SECRET;
10-
11-
12-
export const getSlackInstallUrl = ({
13-
integrationId,
14-
organizationId,
15-
projectId,
16-
}: { integrationId: string; organizationId: string; projectId: string }) => {
7+
export const createSlackInstaller = () => {
8+
const SLACK_CLIENT_ID = process.env.SLACK_CLIENT_ID;
9+
const SLACK_CLIENT_SECRET = process.env.SLACK_CLIENT_SECRET;
10+
const SLACK_STATE_SECRET = process.env.SLACK_STATE_SECRET;
1711
const slackInstaller = new InstallProvider({
1812
clientId: SLACK_CLIENT_ID!,
1913
clientSecret: SLACK_CLIENT_SECRET!,
2014
stateSecret: SLACK_STATE_SECRET,
2115
logLevel: process.env.NODE_ENV === 'development' ? LogLevel.DEBUG : undefined,
2216
});
23-
17+
18+
return slackInstaller;
19+
};
20+
export const getSlackInstallUrl = ({
21+
integrationId,
22+
organizationId,
23+
projectId,
24+
}: { integrationId: string; organizationId: string; projectId: string }) => {
25+
26+
const slackInstaller = createSlackInstaller();
2427
return slackInstaller.generateInstallUrl({
2528
scopes: [
2629
'incoming-webhook',

0 commit comments

Comments
 (0)