The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Let disconnect succeed when stopping webhook subscriptions fails (#26572)
neo773f78211f39aa4
diff --git a/packages/twenty-server/src/engine/metadata-modules/connected-account/connected-account-metadata.service.ts b/packages/twenty-server/src/engine/metadata-modules/connected-account/connected-account-metadata.service.tsindex 11260916623..532a5c0edcd 100644--- a/packages/twenty-server/src/engine/metadata-modules/connected-account/connected-account-metadata.service.ts+++ b/packages/twenty-server/src/engine/metadata-modules/connected-account/connected-account-metadata.service.ts@@ -3,7 +3,11 @@ import { InjectRepository } from '@nestjs/typeorm';import { In, IsNull, Repository } from 'typeorm';-import { ConnectedAccountProvider, EmailOperation } from 'twenty-shared/types';+import {+ ConnectedAccountProvider,+ EmailOperation,+ WebhookSubscriptionStatus,+} from 'twenty-shared/types';import {assertUnreachable,canConnectedAccountPerformEmailOperation,@@ -452,7 +456,12 @@ export class ConnectedAccountMetadataService {messageChannels,calendarChannels,workspaceId,- });+ }).catch((error) =>+ this.logger.warn(+ `WorkspaceId: ${workspaceId} Failed to stop webhook subscriptions while disconnecting connected account ${id}`,+ error,+ ),+ );await this.repository.manager.transaction(async (entityManager) => {await entityManager.update(@@ -484,6 +493,26 @@ export class ConnectedAccountMetadataService {{ connectedAccountId: id, workspaceId },{ isSyncEnabled: false },);++ await entityManager.update(+ MessageChannelEntity,+ {+ connectedAccountId: id,+ workspaceId,+ webhookSubscriptionStatus: WebhookSubscriptionStatus.PENDING,+ },+ { webhookSubscriptionStatus: WebhookSubscriptionStatus.EXPIRED },+ );++ await entityManager.update(+ CalendarChannelEntity,+ {+ connectedAccountId: id,+ workspaceId,+ webhookSubscriptionStatus: WebhookSubscriptionStatus.PENDING,+ },+ { webhookSubscriptionStatus: WebhookSubscriptionStatus.EXPIRED },+ );});return this.repository.findOneOrFail({ where: { id, workspaceId } });