From 8c4dee6cc996178ca401ba4238d33e778a3ea003 Mon Sep 17 00:00:00 2001 From: Stanislas Polu Date: Fri, 19 Jul 2024 19:58:14 +0200 Subject: [PATCH 1/2] clean-up slac --- .../src/connectors/slack/lib/slack_client.ts | 40 +++++++------------ 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/connectors/src/connectors/slack/lib/slack_client.ts b/connectors/src/connectors/slack/lib/slack_client.ts index e6276628f278..8ba9ed98e0f3 100644 --- a/connectors/src/connectors/slack/lib/slack_client.ts +++ b/connectors/src/connectors/slack/lib/slack_client.ts @@ -186,31 +186,19 @@ export async function getSlackConversationInfo( export async function getSlackAccessToken( connectionId: string ): Promise { - if (isDualUseOAuthConnectionId(connectionId)) { - const tokRes = await getOAuthConnectionAccessToken({ - config: apiConfig.getOAuthAPIConfig(), - logger, - provider: "slack", - connectionId, - }); - if (tokRes.isErr()) { - logger.error( - { connectionId, error: tokRes.error }, - "Error retrieving Slack access token" - ); - throw new Error("Error retrieving Slack access token"); - } - - return tokRes.value.access_token; - } else { - // TODO(spolu) SLACK_MIGRATION remove once migrated - if (!NANGO_SLACK_CONNECTOR_ID) { - throw new Error("NANGO_SLACK_CONNECTOR_ID is not defined"); - } - return getAccessTokenFromNango({ - connectionId: connectionId, - integrationId: NANGO_SLACK_CONNECTOR_ID, - useCache: true, - }); + const tokRes = await getOAuthConnectionAccessToken({ + config: apiConfig.getOAuthAPIConfig(), + logger, + provider: "slack", + connectionId, + }); + if (tokRes.isErr()) { + logger.error( + { connectionId, error: tokRes.error }, + "Error retrieving Slack access token" + ); + throw new Error("Error retrieving Slack access token"); } + + return tokRes.value.access_token; } From 14281f4b0eea401bb14c5ea4943237d331dabb3f Mon Sep 17 00:00:00 2001 From: Stanislas Polu Date: Fri, 19 Jul 2024 20:31:43 +0200 Subject: [PATCH 2/2] oauth: clean-up slack --- connectors/src/connectors/slack/index.ts | 10 +--------- connectors/src/connectors/slack/lib/slack_client.ts | 7 ++----- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/connectors/src/connectors/slack/index.ts b/connectors/src/connectors/slack/index.ts index 300d35f3b5a2..dbbfdd9884c9 100644 --- a/connectors/src/connectors/slack/index.ts +++ b/connectors/src/connectors/slack/index.ts @@ -28,8 +28,7 @@ import { ConnectorResource } from "@connectors/resources/connector_resource"; import { SlackConfigurationResource } from "@connectors/resources/slack_configuration_resource"; import type { DataSourceConfig } from "@connectors/types/data_source_config.js"; -const { NANGO_SLACK_CONNECTOR_ID, SLACK_CLIENT_ID, SLACK_CLIENT_SECRET } = - process.env; +const { SLACK_CLIENT_ID, SLACK_CLIENT_SECRET } = process.env; export class SlackConnectorManager extends BaseConnectorManager { static async create({ @@ -88,10 +87,6 @@ export class SlackConnectorManager extends BaseConnectorManager> { - if (!NANGO_SLACK_CONNECTOR_ID) { - throw new Error("NANGO_SLACK_CONNECTOR_ID not set"); - } - const c = await ConnectorResource.fetchById(this.connectorId); if (!c) { logger.error({ connectorId: this.connectorId }, "Connector not found"); @@ -719,9 +714,6 @@ export class SlackConnectorManager extends BaseConnectorManager