Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: pinterest fixes

Nevo David0b3328daebf7
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 db03ea641..9e7320ba3 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 85b7a67cc..0b15ec1a0 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<PinterestSettingsDto>[]
): Promise<PostResponse[]> {
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,
+ })),
},
}),
})