Skip to content

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

fix(tiktok): treat a missing content_posting_method as DIRECT_POST

Gilad Resisi1fb3983bbee9
diff --git a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
index 89a2bbf25..475ddaf44 100644
--- a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
@@ -478,6 +478,18 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
);
}
+ // UPLOAD does not publish - it only drops the media into the user's TikTok
+ // inbox - so only an explicit UPLOAD selects it. A missing value (drafts, or
+ // any caller that skipped the setting) publishes instead of silently landing
+ // in the inbox.
+ private contentPostingMethod(
+ firstPost: PostDetails<TikTokDto>
+ ): TikTokDto['content_posting_method'] {
+ return firstPost?.settings?.content_posting_method === 'UPLOAD'
+ ? 'UPLOAD'
+ : 'DIRECT_POST';
+ }
+
private postingMethod(
method: TikTokDto['content_posting_method'],
isPhoto: boolean
@@ -493,7 +505,7 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
private buildTikokPostInfoBody(firstPost: PostDetails<TikTokDto>) {
const isPhoto = !hasExtension(firstPost?.media?.[0]?.path, 'mp4');
- const method = firstPost?.settings?.content_posting_method;
+ const method = this.contentPostingMethod(firstPost);
if (method === 'DIRECT_POST') {
return {
@@ -750,7 +762,7 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
if (isPhoto) {
return {
post_mode:
- firstPost?.settings?.content_posting_method === 'DIRECT_POST'
+ this.contentPostingMethod(firstPost) === 'DIRECT_POST'
? 'DIRECT_POST'
: 'MEDIA_UPLOAD',
media_type: 'PHOTO',
@@ -796,7 +808,7 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
} = await (
await this.fetch(
`https://open.tiktokapis.com/v2/post/publish${this.postingMethod(
- firstPost.settings.content_posting_method,
+ this.contentPostingMethod(firstPost),
isPhoto
)}`,
{