From 0b3328daebf7c8b84c93eccd8976382d9eb99154 Mon Sep 17 00:00:00 2001 From: Nevo David Date: Mon, 18 May 2026 16:39:38 +0700 Subject: [PATCH] feat: pinterest fixes --- .../providers/pinterest/pinterest.provider.tsx | 7 ++++++- .../integrations/social/pinterest.provider.ts | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/apps/frontend/src/components/new-launch/providers/pinterest/pinterest.provider.tsx b/apps/frontend/src/components/new-launch/providers/pinterest/pinterest.provider.tsx index db03ea64..9e7320ba 100644 --- a/apps/frontend/src/components/new-launch/providers/pinterest/pinterest.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/pinterest/pinterest.provider.tsx @@ -35,13 +35,18 @@ export default withProvider({ CustomPreviewComponent: PinterestPreview, dto: PinterestSettingsDto, checkValidity: async ([firstItem, ...otherItems] = []) => { - const isMp4 = firstItem?.find((item) => (item?.path?.indexOf?.('mp4') ?? -1) > -1); + const isMp4 = firstItem?.find( + (item) => (item?.path?.indexOf?.('mp4') ?? -1) > -1 + ); const isPicture = firstItem?.find( (item) => (item?.path?.indexOf?.('mp4') ?? -1) === -1 ); if ((firstItem?.length ?? 0) === 0) { return 'Requires at least one media'; } + if ((firstItem?.length ?? 0) > 5) { + return 'You can only have up to 5 media items'; + } if (isMp4 && firstItem?.length !== 2 && !isPicture) { return 'If posting a video you have to also include a cover image as second media'; } diff --git a/libraries/nestjs-libraries/src/integrations/social/pinterest.provider.ts b/libraries/nestjs-libraries/src/integrations/social/pinterest.provider.ts index 85b7a67c..0b15ec1a 100644 --- a/libraries/nestjs-libraries/src/integrations/social/pinterest.provider.ts +++ b/libraries/nestjs-libraries/src/integrations/social/pinterest.provider.ts @@ -20,7 +20,7 @@ import { Rules } from '@gitroom/nestjs-libraries/chat/rules.description.decorato import { hasExtension } from '@gitroom/helpers/utils/has.extension'; @Rules( - 'Pinterest requires at least one media, if posting a video, you must have two attachment, one for video, one for the cover picture, When posting a video, there can be only one' + 'Pinterest requires at least one media, if posting a video, you must have two attachment, one for video, one for the cover picture, When posting a video, there can be only one, if posting images, there can be maximum 5' ) export class PinterestProvider extends SocialAbstract @@ -51,6 +51,12 @@ export class PinterestProvider value: string; } | undefined { + if (body.indexOf('constraint: maxItems=5') > -1) { + return { + type: 'bad-body' as const, + value: 'You can upload a maximum of 5 images per post on Pinterest.', + }; + } if (body.indexOf('cover_image_url or cover_image_content_type') > -1) { return { type: 'bad-body' as const, @@ -185,8 +191,8 @@ export class PinterestProvider postDetails: PostDetails[] ): Promise { let mediaId = ''; - const findMp4 = postDetails?.[0]?.media?.find( - (p) => hasExtension(p.path, 'mp4') + const findMp4 = postDetails?.[0]?.media?.find((p) => + hasExtension(p.path, 'mp4') ); const picture = postDetails?.[0]?.media?.find( (p) => !hasExtension(p.path, 'mp4') @@ -292,7 +298,9 @@ export class PinterestProvider } : { source_type: 'multiple_image_urls', - items: mapImages, + items: mapImages.map((m) => ({ + url: m.path, + })), }, }), })