From a3897e1485fe06f7d2c07f41434220e296f1bfd5 Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Sat, 23 May 2026 12:08:49 +0100 Subject: [PATCH] fix(integrations): don't wipe workspace bot row on per-user disconnect --- .../core/integration/repos/integration-connection.repo.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/server/src/core/integration/repos/integration-connection.repo.ts b/apps/server/src/core/integration/repos/integration-connection.repo.ts index 4e6d8136b..841edcbe5 100644 --- a/apps/server/src/core/integration/repos/integration-connection.repo.ts +++ b/apps/server/src/core/integration/repos/integration-connection.repo.ts @@ -169,10 +169,17 @@ export class IntegrationConnectionRepo { trx?: KyselyTransaction, ): Promise { const db = dbOrTx(this.db, trx); + // Never delete a kind='workspace' row from a per-user disconnect. + // For Slack (and any future workspace-scoped provider) the installer's + // userId matches the workspace connection's userId; without this filter + // a single user clicking Disconnect would wipe the shared bot token and + // break the integration for the whole workspace. Full uninstall uses + // deleteByIntegration which intentionally has no kind filter. await db .deleteFrom('integrationConnections') .where('integrationId', '=', integrationId) .where('userId', '=', userId) + .where('kind', '!=', 'workspace') .execute(); }