-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(tiktok): add content posting method alternatives (direct post vs upload) #573
base: main
Are you sure you want to change the base?
Conversation
@keiwanmosaddegh is attempting to deploy a commit to the Listinai Team on Vercel. A member of the Team first needs to authorize it. |
Warning Rate limit exceeded@keiwanmosaddegh has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 0 minutes and 58 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThe changes introduce a new feature for TikTok content posting methods, allowing users to choose between directly posting content or uploading content without posting. This functionality is implemented across multiple files, including the frontend component, data transfer object (DTO), and TikTok integration provider. The modification enables more flexible content management by adding a Changes
Sequence DiagramsequenceDiagram
participant User
participant Frontend
participant Backend
participant TikTokAPI
User->>Frontend: Select content posting method
Frontend->>Backend: Send post request with method
Backend->>Backend: Determine endpoint based on method
alt Direct Post
Backend->>TikTokAPI: Post with post_info
else Upload Only
Backend->>TikTokAPI: Upload without post_info
end
TikTokAPI-->>Backend: Response
Backend-->>Frontend: Return result
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts (1)
229-237
: Simplify the endpoint selection logic.The switch statement can be simplified since 'DIRECT_POST' case and default return the same value.
- const endpoint: string = (() => { - switch (firstPost.settings.content_posting_method) { - case 'UPLOAD': - return '/inbox/video/init/'; - case 'DIRECT_POST': - default: - return '/video/init/'; - } - })(); + const endpoint = firstPost.settings.content_posting_method === 'UPLOAD' + ? '/inbox/video/init/' + : '/video/init/';🧰 Tools
🪛 Biome (1.9.4)
[error] 233-233: Useless case clause.
because the default clause is present:
Unsafe fix: Remove the useless case.
(lint/complexity/noUselessSwitchCase)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx
(2 hunks)libraries/nestjs-libraries/src/dtos/posts/providers-settings/tiktok.dto.ts
(1 hunks)libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
(1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
[error] 233-233: Useless case clause.
because the default clause is present:
Unsafe fix: Remove the useless case.
(lint/complexity/noUselessSwitchCase)
🔇 Additional comments (4)
libraries/nestjs-libraries/src/dtos/posts/providers-settings/tiktok.dto.ts (1)
36-38
: LGTM! Property is well-defined and properly validated.The new
content_posting_method
property is correctly implemented with appropriate validation decorators and type restrictions.libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts (1)
251-261
: LGTM! Clean conditional request body construction.The post_info object is correctly included only for DIRECT_POST method, maintaining a clean separation between posting methods.
apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx (2)
36-45
: LGTM! Well-defined options with clear labels.The content posting method options are clearly defined with descriptive labels that help users understand the difference between the two posting methods.
140-152
: LGTM! Select component is properly integrated.The Select component is well-implemented with:
- Clear labeling
- Proper form registration
- Sensible default value ('DIRECT_POST')
libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
Outdated
Show resolved
Hide resolved
apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts (1)
221-229
: Enhance type safety and simplify switch statement.The method implementation can be improved for better type safety and readability:
- private postingMethod(method: TikTokDto["content_posting_method"]): string { - switch (method) { - case 'UPLOAD': - return '/inbox/video/init/'; - case 'DIRECT_POST': - default: - return '/video/init/'; - } - } + private postingMethod(method: TikTokDto["content_posting_method"]): string { + return method === 'UPLOAD' + ? '/inbox/video/init/' + : '/video/init/'; + }The refactor:
- Simplifies the logic by using a ternary operator
- Removes the redundant case clause flagged by static analysis
🧰 Tools
🪛 Biome (1.9.4)
[error] 225-225: Useless case clause.
because the default clause is present:
Unsafe fix: Remove the useless case.
(lint/complexity/noUselessSwitchCase)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
(1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
[error] 225-225: Useless case clause.
because the default clause is present:
Unsafe fix: Remove the useless case.
(lint/complexity/noUselessSwitchCase)
🔇 Additional comments (1)
libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts (1)
242-242
: Document posting method behaviors and add validation.The conditional inclusion of
post_info
only for 'DIRECT_POST' needs clarification:
- Please add JSDoc comments to document the behavioral differences between posting methods:
/** * Posts content to TikTok using either direct post or upload method. * @param id - The user's ID * @param accessToken - The access token * @param postDetails - Array of post details where the first item contains posting configuration * @param integration - Integration details * * @remarks * - DIRECT_POST: Includes post_info in the request for immediate publishing * - UPLOAD: Excludes post_info to support draft uploads */
- Consider adding validation to ensure required fields are present based on the posting method:
if (firstPost.settings.content_posting_method === 'DIRECT_POST' && !firstPost.message) { throw new Error('Title is required for direct posts'); }
- Run this script to verify the API behavior for both posting methods:
Also applies to: 250-260
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx (1)
141-142
: Fix unescaped single quotes.Replace the single quotes with their HTML entity equivalents to resolve the ESLint warnings.
- 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. + 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.🧰 Tools
🪛 eslint
[error] 141-141:
'
can be escaped with'
,‘
,'
,’
.(react/no-unescaped-entities)
[error] 142-142:
'
can be escaped with'
,‘
,'
,’
.(react/no-unescaped-entities)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx
(2 hunks)
🧰 Additional context used
🪛 eslint
apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx
[error] 141-141: '
can be escaped with '
, ‘
, '
, ’
.
(react/no-unescaped-entities)
[error] 142-142: '
can be escaped with '
, ‘
, '
, ’
.
(react/no-unescaped-entities)
🔇 Additional comments (4)
apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx (4)
36-45
: LGTM! Well-structured options for content posting methods.The constant follows the established pattern and provides clear, descriptive labels for each option.
140-143
: Great addition of explanatory text!The explanation effectively addresses why users might choose to upload without posting, providing clear benefits of this option.
🧰 Tools
🪛 eslint
[error] 141-141:
'
can be escaped with'
,‘
,'
,’
.(react/no-unescaped-entities)
[error] 142-142:
'
can be escaped with'
,‘
,'
,’
.(react/no-unescaped-entities)
144-156
: LGTM! Well-implemented Select component.The component follows the established pattern, properly integrates with form state, and maintains backward compatibility with the default 'DIRECT_POST' value.
146-148
: Verify backend handling of the default value.Ensure that the backend properly handles the default 'DIRECT_POST' value for existing posts and migrations if necessary.
✅ Verification successful
Backend handling of 'DIRECT_POST' value is properly implemented
The backend codebase shows proper type definitions and handling of the 'DIRECT_POST' value:
- Defined as a valid option in
tiktok.dto.ts
- Actively used in conditional logic in
tiktok.provider.ts
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for backend handling of content_posting_method rg -t ts "content_posting_method.*DIRECT_POST" -g "!*test*"Length of output: 338
Script:
#!/bin/bash # Search for migrations or schema definitions related to content_posting_method rg -t ts "content_posting_method" -g "*migration*" -g "*schema*" -g "*entity*"Length of output: 78
@nevo-david ready for your 👀 when you are! |
What kind of change does this PR introduce?
This PR adds the option to pick between direct post and upload on the TikTok posting API.
Why was this change needed?
The current TikTok provider is based on the Direct Post API. The way to extend this and enable TikTok Draft Uploads is by introducing a new TikTok provider variant.
Checklist:
Put a "X" in the boxes below to indicate you have followed the checklist;
Summary by CodeRabbit
New Features
Improvements