feat: fix instagram

This commit is contained in:
Nevo David 2024-10-04 16:53:07 +07:00
parent cf9a2e6990
commit 237bfcbfec
2 changed files with 5 additions and 5 deletions

View File

@ -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,
};
}),
};

View File

@ -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',
}