From 237bfcbfec434b458d0f47118bd0fb32d52e73b3 Mon Sep 17 00:00:00 2001 From: Nevo David Date: Fri, 4 Oct 2024 16:53:07 +0700 Subject: [PATCH] feat: fix instagram --- apps/backend/src/api/routes/integrations.controller.ts | 4 ++-- .../src/integrations/social/instagram.provider.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/backend/src/api/routes/integrations.controller.ts b/apps/backend/src/api/routes/integrations.controller.ts index b0e01043e..f061ab5df 100644 --- a/apps/backend/src/api/routes/integrations.controller.ts +++ b/apps/backend/src/api/routes/integrations.controller.ts @@ -61,8 +61,8 @@ export class IntegrationsController { refreshNeeded: p.refreshNeeded, type: p.type, time: JSON.parse(p.postingTimes), - changeProfilePicture: !!findIntegration.changeProfilePicture, - changeNickName: !!findIntegration.changeNickname, + changeProfilePicture: !!findIntegration?.changeProfilePicture, + changeNickName: !!findIntegration?.changeNickname, }; }), }; diff --git a/libraries/nestjs-libraries/src/integrations/social/instagram.provider.ts b/libraries/nestjs-libraries/src/integrations/social/instagram.provider.ts index 8ae19c734..c9cce36f5 100644 --- a/libraries/nestjs-libraries/src/integrations/social/instagram.provider.ts +++ b/libraries/nestjs-libraries/src/integrations/social/instagram.provider.ts @@ -9,7 +9,6 @@ import { makeId } from '@gitroom/nestjs-libraries/services/make.is'; import { timer } from '@gitroom/helpers/utils/timer'; import dayjs from 'dayjs'; import { SocialAbstract } from '@gitroom/nestjs-libraries/integrations/social.abstract'; -import { chunk } from 'lodash'; export class InstagramProvider extends SocialAbstract @@ -207,7 +206,7 @@ export class InstagramProvider const medias = await Promise.all( firstPost?.media?.map(async (m) => { const caption = - firstPost.media?.length === 1 ? `&caption=${firstPost.message}` : ``; + firstPost.media?.length === 1 ? `&caption=${encodeURIComponent(firstPost.message)}` : ``; const isCarousel = (firstPost?.media?.length || 0) > 1 ? `&is_carousel_item=true` : ``; const mediaType = @@ -216,9 +215,10 @@ export class InstagramProvider ? `video_url=${m.url}&media_type=REELS` : `video_url=${m.url}&media_type=VIDEO` : `image_url=${m.url}`; + const { id: photoId } = await ( await this.fetch( - `https://graph.facebook.com/v20.0/${id}/media?${mediaType}${caption}${isCarousel}&access_token=${accessToken}`, + `https://graph.facebook.com/v20.0/${id}/media?${mediaType}${isCarousel}&access_token=${accessToken}${caption}`, { method: 'POST', }