From 3f674de4016aee2b506a410858ab4bc4272a1d54 Mon Sep 17 00:00:00 2001 From: Nevo David Date: Mon, 5 Jan 2026 21:10:12 +0700 Subject: [PATCH] fix: old providers without selection --- .../src/activities/post.activity.ts | 1 + .../integrations/integration.repository.ts | 10 ++++++++++ .../prisma/integrations/integration.service.ts | 4 ++++ .../refresh.integration.service.ts | 18 ++++++++++++++++-- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/apps/orchestrator/src/activities/post.activity.ts b/apps/orchestrator/src/activities/post.activity.ts index b7e3e027..1db29ca7 100644 --- a/apps/orchestrator/src/activities/post.activity.ts +++ b/apps/orchestrator/src/activities/post.activity.ts @@ -288,6 +288,7 @@ export class PostActivity { return refresh; } catch (err) { + await this._refreshIntegrationService.setBetweenSteps(integration); return false; } } diff --git a/libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.ts b/libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.ts index 6024b921..bb81ae8c 100644 --- a/libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.ts +++ b/libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.ts @@ -309,6 +309,16 @@ export class IntegrationRepository { }); } + async setBetweenRefreshSteps(id: string) { + return this._integration.model.integration.update({ + where: { + id, + }, + data: { + inBetweenSteps: true, + }, + }); + } refreshNeeded(org: string, id: string) { return this._integration.model.integration.update({ where: { diff --git a/libraries/nestjs-libraries/src/database/prisma/integrations/integration.service.ts b/libraries/nestjs-libraries/src/database/prisma/integrations/integration.service.ts index 102f44ca..0a145eb0 100644 --- a/libraries/nestjs-libraries/src/database/prisma/integrations/integration.service.ts +++ b/libraries/nestjs-libraries/src/database/prisma/integrations/integration.service.ts @@ -204,6 +204,10 @@ export class IntegrationService { return this._integrationRepository.refreshNeeded(org, id); } + async setBetweenRefreshSteps(id: string) { + return this._integrationRepository.setBetweenRefreshSteps(id); + } + async refreshTokens() { const integrations = await this._integrationRepository.needsToBeRefreshed(); for (const integration of integrations) { diff --git a/libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts b/libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts index f40e5281..1966aed8 100644 --- a/libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts +++ b/libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts @@ -42,6 +42,14 @@ export class RefreshIntegrationService { return refresh; } + public async setBetweenSteps(integration: Integration) { + await this._integrationService.setBetweenRefreshSteps(integration.id); + await this._integrationService.informAboutRefreshError( + integration.organizationId, + integration + ); + } + private async refreshProcess( integration: Integration, socialProvider: SocialProvider @@ -61,12 +69,18 @@ export class RefreshIntegrationService { integration ); - await this._integrationService.disconnectChannel(integration.organizationId, integration); + await this._integrationService.disconnectChannel( + integration.organizationId, + integration + ); return false; } - if (!socialProvider.reConnect) { + if ( + !socialProvider.reConnect || + integration.rootInternalId === integration.internalId + ) { return refresh; }