Skip to content

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

feat: fix tiktok for photos

Nevo Davidb8e3f53b23a2
diff --git a/apps/frontend/src/components/new-launch/providers/tiktok/tiktok.provider.tsx b/apps/frontend/src/components/new-launch/providers/tiktok/tiktok.provider.tsx
index 45b113afe..df606b9d0 100644
--- a/apps/frontend/src/components/new-launch/providers/tiktok/tiktok.provider.tsx
+++ b/apps/frontend/src/components/new-launch/providers/tiktok/tiktok.provider.tsx
@@ -19,6 +19,8 @@ import { useCustomProviderFunction } from '@gitroom/frontend/components/launches
import { Checkbox } from '@gitroom/react/form/checkbox';
import clsx from 'clsx';
import { useT } from '@gitroom/react/translation/get.transation.service.client';
+import { useIntegration } from '@gitroom/frontend/components/launches/helpers/use.integration';
+import { Input } from '@gitroom/react/form/input';
const CheckTikTokValidity: FC<{
picture: string;
@@ -85,9 +87,14 @@ const CheckTikTokValidity: FC<{
const TikTokSettings: FC<{
values?: any;
}> = (props) => {
- const { watch, register, formState, control } = useSettings();
+ const { watch, register } = useSettings();
+ const { value } = useIntegration();
const t = useT();
+ const isTitle = useMemo(() => {
+ return value?.[0].image.some((p) => p.path.indexOf('mp4') === -1);
+ }, [value]);
+
const disclose = watch('disclose');
const brand_organic_toggle = watch('brand_organic_toggle');
const brand_content_toggle = watch('brand_content_toggle');
@@ -142,6 +149,9 @@ const TikTokSettings: FC<{
return (
<div className="flex flex-col">
<CheckTikTokValidity picture={props?.values?.[0]?.image?.[0]?.path} />
+ {isTitle && (
+ <Input label="Title" {...register('title')} maxLength={90} />
+ )}
<Select
label={t('label_who_can_see_this_video', 'Who can see this video?')}
hideErrors={true}
diff --git a/libraries/nestjs-libraries/src/dtos/posts/providers-settings/tiktok.dto.ts b/libraries/nestjs-libraries/src/dtos/posts/providers-settings/tiktok.dto.ts
index 1c0c4de3f..dfeed9e1e 100644
--- a/libraries/nestjs-libraries/src/dtos/posts/providers-settings/tiktok.dto.ts
+++ b/libraries/nestjs-libraries/src/dtos/posts/providers-settings/tiktok.dto.ts
@@ -1,6 +1,10 @@
-import { IsBoolean, IsDefined, IsIn, IsString } from 'class-validator';
+import { IsBoolean, ValidateIf, IsIn, IsString, MaxLength } from 'class-validator';
export class TikTokDto {
+ @ValidateIf(p => p.title)
+ @MaxLength(90)
+ title: string;
+
@IsIn([
'PUBLIC_TO_EVERYONE',
'MUTUAL_FOLLOW_FRIENDS',
@@ -32,10 +36,6 @@ export class TikTokDto {
@IsBoolean()
brand_organic_toggle: boolean;
- // @IsIn(['true'])
- // @IsDefined()
- // isValidVideo: boolean;
-
@IsIn(['DIRECT_POST', 'UPLOAD'])
@IsString()
content_posting_method: 'DIRECT_POST' | 'UPLOAD';
diff --git a/libraries/nestjs-libraries/src/integrations/social/facebook.provider.ts b/libraries/nestjs-libraries/src/integrations/social/facebook.provider.ts
index a5d68f6f3..5d01d0ce6 100644
--- a/libraries/nestjs-libraries/src/integrations/social/facebook.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/facebook.provider.ts
@@ -66,6 +66,13 @@ export class FacebookProvider extends SocialAbstract implements SocialProvider {
};
}
+ if (body.indexOf('1404006') > -1) {
+ return {
+ type: 'bad-body' as const,
+ value: "We couldn't post your comment, A security check in facebook required to proceed.",
+ };
+ }
+
if (body.indexOf('1404102') > -1) {
return {
type: 'bad-body' as const,
diff --git a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
index d33905331..b0dfb5fde 100644
--- a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
@@ -63,7 +63,63 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
};
}
- // Spam/Policy errors
+ if (body.indexOf('file_format_check_failed') > -1) {
+ return {
+ type: 'bad-body' as const,
+ value: 'File format is invalid, please check video specifications',
+ };
+ }
+
+ if (body.indexOf('duration_check_failed') > -1) {
+ return {
+ type: 'bad-body' as const,
+ value: 'Video duration is invalid, please check video specifications',
+ };
+ }
+
+ if (body.indexOf('frame_rate_check_failed') > -1) {
+ return {
+ type: 'bad-body' as const,
+ value: 'Video frame rate is invalid, please check video specifications',
+ };
+ }
+
+ if (body.indexOf('video_pull_failed') > -1) {
+ return {
+ type: 'bad-body' as const,
+ value: 'Failed to pull video from URL, please check the URL',
+ };
+ }
+
+ if (body.indexOf('photo_pull_failed') > -1) {
+ return {
+ type: 'bad-body' as const,
+ value: 'Failed to pull photo from URL, please check the URL',
+ };
+ }
+
+ if (body.indexOf('spam_risk_user_banned_from_posting') > -1) {
+ return {
+ type: 'bad-body' as const,
+ value:
+ 'Account banned from posting, please check TikTok account status',
+ };
+ }
+
+ if (body.indexOf('spam_risk_text') > -1) {
+ return {
+ type: 'bad-body' as const,
+ value: 'TikTok detected potential spam in the post text',
+ };
+ }
+
+ if (body.indexOf('spam_risk') > -1) {
+ return {
+ type: 'bad-body' as const,
+ value: 'TikTok detected potential spam',
+ };
+ }
+
if (body.indexOf('spam_risk_too_many_posts') > -1) {
return {
type: 'bad-body' as const,
@@ -125,14 +181,21 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
}
// Server errors
- if (body.indexOf('internal_error') > -1) {
+ if (body.indexOf('internal') > -1) {
return {
type: 'bad-body' as const,
- value: 'TikTok server error, please try again later',
+ value: 'There is a problem with TikTok servers, please try again later',
};
}
// Generic TikTok API errors
+ if (body.indexOf('picture_size_check_failed') > -1) {
+ return {
+ type: 'bad-body' as const,
+ value: 'Picture size is invalid',
+ };
+ }
+
if (body.indexOf('TikTok API error') > -1) {
return {
type: 'bad-body' as const,
@@ -358,8 +421,9 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
postDetails: PostDetails<TikTokDto>[],
integration: Integration
): Promise<PostResponse[]> {
- const [firstPost, ...comments] = postDetails;
+ const [firstPost] = postDetails;
+ const isPhoto = (firstPost?.media?.[0]?.path?.indexOf('mp4') || -1) === -1;
const {
data: { publish_id },
} = await (
@@ -379,8 +443,17 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
'DIRECT_POST') === 'DIRECT_POST'
? {
post_info: {
- title: firstPost.message,
- privacy_level: firstPost.settings.privacy_level || 'PUBLIC_TO_EVERYONE',
+ ...((firstPost?.settings?.title && isPhoto) ||
+ (firstPost.message && !isPhoto)
+ ? {
+ title: isPhoto
+ ? firstPost.settings.title
+ : firstPost.message,
+ }
+ : {}),
+ ...(isPhoto ? { description: firstPost.message } : {}),
+ privacy_level:
+ firstPost.settings.privacy_level || 'PUBLIC_TO_EVERYONE',
disable_duet: !firstPost.settings.duet || false,
disable_comment: !firstPost.settings.comment || false,
disable_stitch: !firstPost.settings.stitch || false,