Skip to content

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

feat: assert boolean

Nevo David40324535d8f1
diff --git a/libraries/nestjs-libraries/src/integrations/social.abstract.ts b/libraries/nestjs-libraries/src/integrations/social.abstract.ts
index c09f7a857..de55855a6 100644
--- a/libraries/nestjs-libraries/src/integrations/social.abstract.ts
+++ b/libraries/nestjs-libraries/src/integrations/social.abstract.ts
@@ -85,6 +85,13 @@ export abstract class SocialAbstract {
return true;
}
+ protected assetBoolean(value: boolean | string) {
+ if (typeof value === 'string') {
+ return value.toLowerCase() === 'true';
+ }
+ return value || false;
+ }
+
/** Reads the pixel dimensions of an image via sharp (works for http or local paths). */
protected async getImageDimensions(
path: string
@@ -136,7 +143,12 @@ export abstract class SocialAbstract {
value.value || ''
);
}
- throw new BadBody('', safeStringify(globalErr), {} as any, value.value || '');
+ throw new BadBody(
+ '',
+ safeStringify(globalErr),
+ {} as any,
+ value.value || ''
+ );
}
return value;
@@ -148,7 +160,7 @@ export abstract class SocialAbstract {
identifier = '',
totalRetries = 0,
ignoreConcurrency = false,
- message = '',
+ message = ''
): Promise<Response> {
const request = await fetch(url, options);
diff --git a/libraries/nestjs-libraries/src/integrations/social/instagram.provider.ts b/libraries/nestjs-libraries/src/integrations/social/instagram.provider.ts
index d9461d590..de15d414c 100644
--- a/libraries/nestjs-libraries/src/integrations/social/instagram.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/instagram.provider.ts
@@ -55,7 +55,7 @@ export class InstagramProvider
if (firstPost.length > 10) {
return 'Instagram carousel only supports up to 10 media attachments';
}
- if (settings?.is_trial_reel) {
+ if (this.assetBoolean(settings?.is_trial_reel)) {
if ((firstPost?.length ?? 0) > 1) {
return 'Trial Reels can only have one video';
}
@@ -605,7 +605,7 @@ export class InstagramProvider
const [firstPost] = postDetails;
console.log('in progress', id);
const isStory = firstPost.settings.post_type === 'story';
- const isTrialReel = !!firstPost.settings.is_trial_reel;
+ const isTrialReel = this.assetBoolean(firstPost.settings.is_trial_reel);
const medias = await Promise.all(
firstPost?.media?.map(async (m) => {
const caption =
diff --git a/libraries/nestjs-libraries/src/integrations/social/instagram.standalone.provider.ts b/libraries/nestjs-libraries/src/integrations/social/instagram.standalone.provider.ts
index c1e649f72..039690cea 100644
--- a/libraries/nestjs-libraries/src/integrations/social/instagram.standalone.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/instagram.standalone.provider.ts
@@ -49,7 +49,7 @@ export class InstagramStandaloneProvider
if (!firstPost?.length) {
return 'Should have at least one media';
}
- if (settings?.is_trial_reel) {
+ if (this.assetBoolean(settings?.is_trial_reel)) {
if ((firstPost?.length ?? 0) > 1) {
return 'Trial Reels can only have one video';
}
diff --git a/libraries/nestjs-libraries/src/integrations/social/linkedin.provider.ts b/libraries/nestjs-libraries/src/integrations/social/linkedin.provider.ts
index 050178452..e7224b902 100644
--- a/libraries/nestjs-libraries/src/integrations/social/linkedin.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/linkedin.provider.ts
@@ -54,7 +54,7 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
const [firstPost, ...restPosts] = posts ?? [];
if (
- vals?.post_as_images_carousel &&
+ this.assetBoolean(vals?.post_as_images_carousel) &&
((firstPost?.length ?? 0) < 2 ||
firstPost?.some((p) => (p?.path?.indexOf?.('mp4') ?? -1) > -1))
) {
@@ -792,7 +792,7 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
const [firstPost] = postDetails;
// Check if we should convert images to PDF carousel
- if (firstPost.settings?.post_as_images_carousel) {
+ if (this.assetBoolean(firstPost.settings?.post_as_images_carousel)) {
processedPostDetails = await this.convertImagesToPdfCarousel(
postDetails,
firstPost
@@ -821,7 +821,7 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
processedFirstPost,
mainPostMediaIds,
type,
- !!firstPost.settings?.post_as_images_carousel
+ this.assetBoolean(firstPost.settings?.post_as_images_carousel)
);
// Return response for main post only
diff --git a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
index e329f86bb..b8f7cbbe7 100644
--- a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
@@ -480,13 +480,6 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
}
}
- private assetBoolean(value: boolean | string) {
- if (typeof value === 'string') {
- return value.toLowerCase() === 'true';
- }
- return value || false;
- }
-
private buildTikokPostInfoBody(firstPost: PostDetails<TikTokDto>) {
const isPhoto = !hasExtension(firstPost?.media?.[0]?.path, 'mp4');
const method = firstPost?.settings?.content_posting_method;
diff --git a/libraries/nestjs-libraries/src/integrations/social/x.provider.ts b/libraries/nestjs-libraries/src/integrations/social/x.provider.ts
index 25d71615b..22a85f73d 100644
--- a/libraries/nestjs-libraries/src/integrations/social/x.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/x.provider.ts
@@ -509,8 +509,8 @@ export class XProvider extends SocialAbstract implements SocialProvider {
? removeLinks(firstPost.message)
: firstPost.message,
...(media_ids.length ? { media: { media_ids } } : {}),
- made_with_ai: !!firstPost?.settings?.made_with_ai,
- paid_partnership: !!firstPost?.settings?.paid_partnership,
+ made_with_ai: this.assetBoolean(firstPost?.settings?.made_with_ai),
+ paid_partnership: this.assetBoolean(firstPost?.settings?.paid_partnership),
};
const tweetResponse = await this.fetch(tweetUrl, {
@@ -571,8 +571,10 @@ export class XProvider extends SocialAbstract implements SocialProvider {
: commentPost.message,
...(media_ids.length ? { media: { media_ids } } : {}),
reply: { in_reply_to_tweet_id: replyToId },
- made_with_ai: !!commentPost?.settings?.made_with_ai,
- paid_partnership: !!commentPost?.settings?.paid_partnership,
+ made_with_ai: this.assetBoolean(commentPost?.settings?.made_with_ai),
+ paid_partnership: this.assetBoolean(
+ commentPost?.settings?.paid_partnership
+ ),
};
const tweetResponse = await this.fetch(tweetUrl, {