diff --git a/apps/orchestrator/src/workflows/post.workflow.ts b/apps/orchestrator/src/workflows/post.workflow.ts index 135cda74..cf9c711f 100644 --- a/apps/orchestrator/src/workflows/post.workflow.ts +++ b/apps/orchestrator/src/workflows/post.workflow.ts @@ -172,7 +172,7 @@ export async function postWorkflow({ err.cause.type === 'refresh_token' ) { const refresh = await refreshToken(post.integration); - if (!refresh) { + if (!refresh || !refresh.accessToken) { return false; } @@ -286,7 +286,7 @@ export async function postWorkflow({ err.cause.type === 'refresh_token' ) { const refresh = await refreshToken(post.integration); - if (!refresh) { + if (!refresh || !refresh.accessToken) { return false; } @@ -328,7 +328,7 @@ export async function postWorkflow({ err.cause.type === 'refresh_token' ) { const refresh = await refreshToken(post.integration); - if (!refresh) { + if (!refresh || !refresh.accessToken) { return false; } diff --git a/libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts b/libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts index 80f7e3d7..f40e5281 100644 --- a/libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts +++ b/libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts @@ -50,7 +50,7 @@ export class RefreshIntegrationService { .refreshToken(integration.refreshToken) .catch((err) => false); - if (!refresh) { + if (!refresh || !refresh.accessToken) { await this._integrationService.refreshNeeded( integration.organizationId, integration.id diff --git a/libraries/nestjs-libraries/src/integrations/social/x.provider.ts b/libraries/nestjs-libraries/src/integrations/social/x.provider.ts index 5dccf2dc..95e7559c 100644 --- a/libraries/nestjs-libraries/src/integrations/social/x.provider.ts +++ b/libraries/nestjs-libraries/src/integrations/social/x.provider.ts @@ -45,15 +45,22 @@ export class XProvider extends SocialAbstract implements SocialProvider { value: string; } | undefined { - if (body.includes('usage-capped')) { + if (body.includes('Unsupported Authentication')) { return { type: 'refresh-token', + value: 'X authentication has expired, please reconnect your account', + }; + } + + if (body.includes('usage-capped')) { + return { + type: 'bad-body', value: 'Posting failed - capped reached. Please try again later', }; } if (body.includes('duplicate-rules')) { return { - type: 'refresh-token', + type: 'bad-body', value: 'You have already posted this post, please wait before posting again', };