Skip to content

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

fix(tiktok): extract endopoint method outside of post()

Keiwan Mosaddeghaa3ffac193d4
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<PostResponse[]> {
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: {