Skip to content

Commit

Permalink
feat: fix instagram
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevo David committed Oct 4, 2024
1 parent cf9a2e6 commit 237bfcb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/backend/src/api/routes/integrations.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 =
Expand All @@ -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',
}
Expand Down

0 comments on commit 237bfcb

Please sign in to comment.