From 13b26030b4099b9a99f5c248943973804d807059 Mon Sep 17 00:00:00 2001 From: Keiwan Mosaddegh Date: Thu, 23 Jan 2025 09:49:08 +0100 Subject: [PATCH 1/7] feat(tiktok): add content posting method to tiktok dto --- .../src/dtos/posts/providers-settings/tiktok.dto.ts | 4 ++++ 1 file changed, 4 insertions(+) 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 28c49024f..91eece6cc 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 @@ -32,4 +32,8 @@ export class TikTokDto { @IsIn(['true']) @IsDefined() isValidVideo: boolean; + + @IsIn(['DIRECT_POST', 'UPLOAD']) + @IsString() + content_posting_method: 'DIRECT_POST' | 'UPLOAD'; } From 912895b6c7a9f9756aed441df73fe9cd8731c7cf Mon Sep 17 00:00:00 2001 From: Keiwan Mosaddegh Date: Thu, 23 Jan 2025 09:52:12 +0100 Subject: [PATCH 2/7] feat(tiktok): add content posting method alternative to settings --- .../providers/tiktok/tiktok.provider.tsx | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx b/apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx index 6f2ca47cc..6b704027e 100644 --- a/apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx +++ b/apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx @@ -33,6 +33,17 @@ const privacyLevel = [ }, ]; +const contentPostingMethod = [ + { + value: 'DIRECT_POST', + label: 'Post content directly to TikTok', + }, + { + value: 'UPLOAD', + label: 'Upload content to TikTok without posting it', + }, +]; + const yesNo = [ { value: 'true', @@ -126,6 +137,19 @@ const TikTokSettings: FC<{ values?: any }> = (props) => { ))} +
Allow User To:
From 81eacbe6d5bb14da56b3efc75d17e73416a017de Mon Sep 17 00:00:00 2001 From: Keiwan Mosaddegh Date: Thu, 23 Jan 2025 10:09:35 +0100 Subject: [PATCH 3/7] feat(tiktok): update conetnt posting method based on setting --- .../integrations/social/tiktok.provider.ts | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts index aa299b419..1cbb39cbe 100644 --- a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts +++ b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts @@ -226,11 +226,21 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider { ): Promise { const [firstPost, ...comments] = postDetails; + const endpoint: string = (() => { + switch (firstPost.settings.content_posting_method) { + case 'UPLOAD': + return '/inbox/video/init/'; + case 'DIRECT_POST': + default: + return '/video/init/'; + } + })(); + const { data: { publish_id }, } = await ( await this.fetch( - 'https://open.tiktokapis.com/v2/post/publish/video/init/', + `https://open.tiktokapis.com/v2/post/publish${endpoint}`, { method: 'POST', headers: { @@ -238,15 +248,17 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider { Authorization: `Bearer ${accessToken}`, }, body: JSON.stringify({ - post_info: { - title: firstPost.message, - privacy_level: firstPost.settings.privacy_level, - disable_duet: !firstPost.settings.duet, - disable_comment: !firstPost.settings.comment, - disable_stitch: !firstPost.settings.stitch, - brand_content_toggle: firstPost.settings.brand_content_toggle, - brand_organic_toggle: firstPost.settings.brand_organic_toggle, - }, + ...(firstPost.settings.content_posting_method === 'DIRECT_POST' ? { + post_info: { + title: firstPost.message, + privacy_level: firstPost.settings.privacy_level, + disable_duet: !firstPost.settings.duet, + disable_comment: !firstPost.settings.comment, + disable_stitch: !firstPost.settings.stitch, + brand_content_toggle: firstPost.settings.brand_content_toggle, + brand_organic_toggle: firstPost.settings.brand_organic_toggle, + } + } : {}), source_info: { source: 'PULL_FROM_URL', video_url: firstPost?.media?.[0]?.url!, From aa3ffac193d4d1adcd294b64dead441a3e7986ff Mon Sep 17 00:00:00 2001 From: Keiwan Mosaddegh Date: Thu, 23 Jan 2025 10:29:50 +0100 Subject: [PATCH 4/7] fix(tiktok): extract endopoint method outside of post() --- .../integrations/social/tiktok.provider.ts | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts index 1cbb39cbe..14b4b0c5a 100644 --- a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts +++ b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts @@ -218,6 +218,16 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider { } } + private postingMethod(method: TikTokDto["content_posting_method"]): string { + switch (method) { + case 'UPLOAD': + return '/inbox/video/init/'; + case 'DIRECT_POST': + default: + return '/video/init/'; + } + } + async post( id: string, accessToken: string, @@ -225,22 +235,11 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider { integration: Integration ): Promise { const [firstPost, ...comments] = postDetails; - - const endpoint: string = (() => { - switch (firstPost.settings.content_posting_method) { - case 'UPLOAD': - return '/inbox/video/init/'; - case 'DIRECT_POST': - default: - return '/video/init/'; - } - })(); - const { data: { publish_id }, } = await ( await this.fetch( - `https://open.tiktokapis.com/v2/post/publish${endpoint}`, + `https://open.tiktokapis.com/v2/post/publish${this.postingMethod(firstPost.settings.content_posting_method)}`, { method: 'POST', headers: { From 1df0b98de7eae8c977ccd62e07c483455b0bdb09 Mon Sep 17 00:00:00 2001 From: Keiwan Mosaddegh Date: Thu, 23 Jan 2025 10:46:23 +0100 Subject: [PATCH 5/7] fix(tiktok): add explanation about example use case for upload method --- .../components/launches/providers/tiktok/tiktok.provider.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx b/apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx index 6b704027e..88af11a87 100644 --- a/apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx +++ b/apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx @@ -137,6 +137,10 @@ const TikTokSettings: FC<{ values?: any }> = (props) => { ))} +
+ Choose upload without posting if you want to review and edit your content within TikTok's app before publishing. + This gives you access to TikTok's built-in editing tools and lets you make final adjustments before posting. +
= (props) => {