Skip to content

Commit

Permalink
[Slack] Fix connector deletion when OAuth isn't valid. (#2447)
Browse files Browse the repository at this point in the history
  • Loading branch information
lasryaric authored Nov 8, 2023
1 parent 1110431 commit 2432fe4
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions connectors/src/connectors/slack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,23 @@ export async function cleanupSlackConnector(
return new Err(new Error("SLACK_CLIENT_SECRET is not defined"));
}

const slackClient = await getSlackClient(connector.id);
const deleteRes = await slackClient.apps.uninstall({
client_id: SLACK_CLIENT_ID,
client_secret: SLACK_CLIENT_SECRET,
});
if (deleteRes && !deleteRes.ok) {
return new Err(
new Error(
`Could not uninstall the Slack app from the user's workspace. Error: ${deleteRes.error}`
)
try {
const slackClient = await getSlackClient(connector.id);
const deleteRes = await slackClient.apps.uninstall({
client_id: SLACK_CLIENT_ID,
client_secret: SLACK_CLIENT_SECRET,
});
if (deleteRes && !deleteRes.ok) {
return new Err(
new Error(
`Could not uninstall the Slack app from the user's workspace. Error: ${deleteRes.error}`
)
);
}
} catch (e) {
logger.error(
{ connectorId: connectorId, error: e },
"Could not uninstall the Slack app from the user's workspace."
);
}

Expand Down

0 comments on commit 2432fe4

Please sign in to comment.