From ff4ee6c5fe6f2e683f2fb442a8dd4c79c8773d12 Mon Sep 17 00:00:00 2001 From: Nevo David Date: Mon, 2 Mar 2026 20:25:33 +0700 Subject: [PATCH] feat: maximum 500 --- .../src/integrations/social.abstract.ts | 6 +++--- .../src/integrations/social/threads.provider.ts | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libraries/nestjs-libraries/src/integrations/social.abstract.ts b/libraries/nestjs-libraries/src/integrations/social.abstract.ts index 10795896..ec13f7f6 100644 --- a/libraries/nestjs-libraries/src/integrations/social.abstract.ts +++ b/libraries/nestjs-libraries/src/integrations/social.abstract.ts @@ -121,9 +121,11 @@ export abstract class SocialAbstract { json = '{}'; } + const handleError = this.handleErrors(json || '{}'); + if ( request.status === 429 || - request.status === 500 || + (request.status === 500 && !handleError) || json.includes('rate_limit_exceeded') || json.includes('Rate limit') ) { @@ -137,8 +139,6 @@ export abstract class SocialAbstract { ); } - const handleError = this.handleErrors(json || '{}'); - if (handleError?.type === 'retry') { await timer(5000); return this.fetch( diff --git a/libraries/nestjs-libraries/src/integrations/social/threads.provider.ts b/libraries/nestjs-libraries/src/integrations/social/threads.provider.ts index eca2307d..30cbee04 100644 --- a/libraries/nestjs-libraries/src/integrations/social/threads.provider.ts +++ b/libraries/nestjs-libraries/src/integrations/social/threads.provider.ts @@ -39,10 +39,18 @@ export class ThreadsProvider extends SocialAbstract implements SocialProvider { value: string; } | undefined { + console.log(body); if (body.includes('Error validating access token')) { return { type: 'refresh-token', value: 'Threads access token expired' }; } + if (body.includes('text must be at most 500 characters')) { + return { + type: 'bad-body', + value: 'Post text exceeds 500 characters limit', + }; + } + return undefined; } @@ -270,7 +278,7 @@ export class ThreadsProvider extends SocialAbstract implements SocialProvider { form.append('quote_post_id', quoteId); } - const { id: contentId } = await ( + const { id: contentId, ...all } = await ( await this.fetch(`https://graph.threads.net/v1.0/${userId}/threads`, { method: 'POST', body: form,