@@ -63,7 +63,63 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
6363 } ;
6464 }
6565
66- // Spam/Policy errors
66+ if ( body . indexOf ( 'file_format_check_failed' ) > - 1 ) {
67+ return {
68+ type : 'bad-body' as const ,
69+ value : 'File format is invalid, please check video specifications' ,
70+ } ;
71+ }
72+
73+ if ( body . indexOf ( 'duration_check_failed' ) > - 1 ) {
74+ return {
75+ type : 'bad-body' as const ,
76+ value : 'Video duration is invalid, please check video specifications' ,
77+ } ;
78+ }
79+
80+ if ( body . indexOf ( 'frame_rate_check_failed' ) > - 1 ) {
81+ return {
82+ type : 'bad-body' as const ,
83+ value : 'Video frame rate is invalid, please check video specifications' ,
84+ } ;
85+ }
86+
87+ if ( body . indexOf ( 'video_pull_failed' ) > - 1 ) {
88+ return {
89+ type : 'bad-body' as const ,
90+ value : 'Failed to pull video from URL, please check the URL' ,
91+ } ;
92+ }
93+
94+ if ( body . indexOf ( 'photo_pull_failed' ) > - 1 ) {
95+ return {
96+ type : 'bad-body' as const ,
97+ value : 'Failed to pull photo from URL, please check the URL' ,
98+ } ;
99+ }
100+
101+ if ( body . indexOf ( 'spam_risk_user_banned_from_posting' ) > - 1 ) {
102+ return {
103+ type : 'bad-body' as const ,
104+ value :
105+ 'Account banned from posting, please check TikTok account status' ,
106+ } ;
107+ }
108+
109+ if ( body . indexOf ( 'spam_risk_text' ) > - 1 ) {
110+ return {
111+ type : 'bad-body' as const ,
112+ value : 'TikTok detected potential spam in the post text' ,
113+ } ;
114+ }
115+
116+ if ( body . indexOf ( 'spam_risk' ) > - 1 ) {
117+ return {
118+ type : 'bad-body' as const ,
119+ value : 'TikTok detected potential spam' ,
120+ } ;
121+ }
122+
67123 if ( body . indexOf ( 'spam_risk_too_many_posts' ) > - 1 ) {
68124 return {
69125 type : 'bad-body' as const ,
@@ -125,14 +181,21 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
125181 }
126182
127183 // Server errors
128- if ( body . indexOf ( 'internal_error ' ) > - 1 ) {
184+ if ( body . indexOf ( 'internal ' ) > - 1 ) {
129185 return {
130186 type : 'bad-body' as const ,
131- value : 'TikTok server error , please try again later' ,
187+ value : 'There is a problem with TikTok servers , please try again later' ,
132188 } ;
133189 }
134190
135191 // Generic TikTok API errors
192+ if ( body . indexOf ( 'picture_size_check_failed' ) > - 1 ) {
193+ return {
194+ type : 'bad-body' as const ,
195+ value : 'Picture size is invalid' ,
196+ } ;
197+ }
198+
136199 if ( body . indexOf ( 'TikTok API error' ) > - 1 ) {
137200 return {
138201 type : 'bad-body' as const ,
@@ -358,8 +421,9 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
358421 postDetails : PostDetails < TikTokDto > [ ] ,
359422 integration : Integration
360423 ) : Promise < PostResponse [ ] > {
361- const [ firstPost , ... comments ] = postDetails ;
424+ const [ firstPost ] = postDetails ;
362425
426+ const isPhoto = ( firstPost ?. media ?. [ 0 ] ?. path ?. indexOf ( 'mp4' ) || - 1 ) === - 1 ;
363427 const {
364428 data : { publish_id } ,
365429 } = await (
@@ -379,8 +443,17 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
379443 'DIRECT_POST' ) === 'DIRECT_POST'
380444 ? {
381445 post_info : {
382- title : firstPost . message ,
383- privacy_level : firstPost . settings . privacy_level || 'PUBLIC_TO_EVERYONE' ,
446+ ...( ( firstPost ?. settings ?. title && isPhoto ) ||
447+ ( firstPost . message && ! isPhoto )
448+ ? {
449+ title : isPhoto
450+ ? firstPost . settings . title
451+ : firstPost . message ,
452+ }
453+ : { } ) ,
454+ ...( isPhoto ? { description : firstPost . message } : { } ) ,
455+ privacy_level :
456+ firstPost . settings . privacy_level || 'PUBLIC_TO_EVERYONE' ,
384457 disable_duet : ! firstPost . settings . duet || false ,
385458 disable_comment : ! firstPost . settings . comment || false ,
386459 disable_stitch : ! firstPost . settings . stitch || false ,
0 commit comments