From 8b0994f8c77b8ff49fa8cad94c7250ea8b3c62d0 Mon Sep 17 00:00:00 2001 From: Nevo David Date: Fri, 11 Jul 2025 12:37:05 +0700 Subject: [PATCH] feat: instagram returns refresh token, but it's actually that the user post too much --- .../nestjs-libraries/src/integrations/social.abstract.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libraries/nestjs-libraries/src/integrations/social.abstract.ts b/libraries/nestjs-libraries/src/integrations/social.abstract.ts index 6bf2b69b..00234ce2 100644 --- a/libraries/nestjs-libraries/src/integrations/social.abstract.ts +++ b/libraries/nestjs-libraries/src/integrations/social.abstract.ts @@ -69,12 +69,9 @@ export abstract class SocialAbstract { return this.fetch(url, options, identifier, totalRetries + 1); } - const handleError = this.handleErrors(json || '{}') || { - type: 'bad-body', - value: '', - }; + const handleError = this.handleErrors(json || '{}'); - if (request.status === 401 || handleError?.type === 'refresh-token') { + if (request.status === 401 && (handleError?.type === 'refresh-token' || !handleError)) { console.log('refresh token', json); throw new RefreshToken( identifier, @@ -84,7 +81,7 @@ export abstract class SocialAbstract { ); } - throw new BadBody(identifier, json, options.body!, handleError?.value); + throw new BadBody(identifier, json, options.body!, handleError?.value || ''); } checkScopes(required: string[], got: string | string[]) {