-
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. |
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
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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! |
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.
LGTM.
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.
@keiwanmosaddegh LGTM.
Hey, I don't think this is really needed, because Postiz was made to schedule a post to directly post it, with this Feature, you can just upload it yourself, this doesn't require Postiz. |
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: 1
📜 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
(7 hunks)
🧰 Additional context used
🪛 ESLint
apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx
[error] 145-145: '
can be escaped with '
, ‘
, '
, ’
.
(react/no-unescaped-entities)
[error] 146-146: '
can be escaped with '
, ‘
, '
, ’
.
(react/no-unescaped-entities)
🔇 Additional comments (6)
apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx (6)
36-45
: New ConstantcontentPostingMethod
Defined
The new constant cleanly defines the available posting methods. For improved maintainability, consider adding a brief inline comment explaining its purpose and usage in relation to the posting options.
123-123
: Watching the Posting Method Value
The hook call usingwatch('content_posting_method')
correctly retrieves the form value for the posting method.
125-125
: Determining Upload Mode
The booleanisUploadMode
is correctly set based on whether the posting method equals'UPLOAD'
. This variable is then used to conditionally disable dependent fields.
Line range hint
132-140
: Conditional Disabling of Privacy Level Select
Disabling the privacy level<Select>
when in upload mode is consistent with the intended business logic, assuming privacy settings are not applicable during a draft upload.
144-147
: Descriptive Text for Upload Option (Addressing Prior Feedback & ESLint Warnings)
The newly added text explains why a user might choose the upload option, effectively addressing the previous comment about providing context. However, ESLint reports unescaped apostrophes on these lines. Consider replacing apostrophes with HTML entities (e.g.,’
) or refactoring the text to avoid the warning.🧰 Tools
🪛 ESLint
[error] 145-145:
'
can be escaped with'
,‘
,'
,’
.(react/no-unescaped-entities)
[error] 146-146:
'
can be escaped with'
,‘
,'
,’
.(react/no-unescaped-entities)
168-176
: Conditional Disabling of Feature Checkboxes
Disabling the "Duet", "Stitch", and "Comments" checkboxes when in upload mode enforces the intended restrictions. This use ofdisabled={isUploadMode}
maintains consistency with the form behavior.
<Select | ||
label="Content posting method" | ||
disabled={isUploadMode} | ||
{...register('content_posting_method', { | ||
value: 'DIRECT_POST', | ||
})} | ||
> | ||
<option value="">Select</option> | ||
{contentPostingMethod.map((item) => ( | ||
<option key={item.value} value={item.value}> | ||
{item.label} | ||
</option> | ||
))} | ||
</Select> |
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.
🛠️ Refactor suggestion
Review the 'Content Posting Method' Select Disabled Prop
The <Select>
element for choosing the content posting method is currently disabled when isUploadMode
is true. This behavior will lock the selection to 'UPLOAD'
once chosen, preventing the user from toggling back to 'DIRECT_POST'
. It is likely that the posting method control should remain enabled at all times to allow switching.
Proposed change:
- <Select
- label="Content posting method"
- disabled={isUploadMode}
- {...register('content_posting_method', {
- value: 'DIRECT_POST',
- })}
- >
+ <Select
+ label="Content posting method"
+ {...register('content_posting_method', {
+ value: 'DIRECT_POST',
+ })}
+ >
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
<Select | |
label="Content posting method" | |
disabled={isUploadMode} | |
{...register('content_posting_method', { | |
value: 'DIRECT_POST', | |
})} | |
> | |
<option value="">Select</option> | |
{contentPostingMethod.map((item) => ( | |
<option key={item.value} value={item.value}> | |
{item.label} | |
</option> | |
))} | |
</Select> | |
<Select | |
label="Content posting method" | |
{...register('content_posting_method', { | |
value: 'DIRECT_POST', | |
})} | |
> | |
<option value="">Select</option> | |
{contentPostingMethod.map((item) => ( | |
<option key={item.value} value={item.value}> | |
{item.label} | |
</option> | |
))} | |
</Select> |
apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx
Fixed
Show fixed
Hide fixed
apps/frontend/src/components/launches/providers/tiktok/tiktok.provider.tsx
Fixed
Show fixed
Hide fixed
@egelhaus I had a discussion with @nevo-david about this in #off-topic (sorry about that hehe). The reason why there is a need for this is because you can't add TikTok sounds to a video through the direct posting API. However, if you push the videos to TikTok draft you can edit them before posting. I know it isn't scheduled and posted directly to the public, however it's scheduled and posted to the TikTok platform where there is someone who processes the video and ultimately posts it. Does that make sense to you? |
Hey, Yes it does make sense to me that the TikTok Editor is better than ours. It still defeats the Scheduling Putpose, but alright, this will make sense in a specific Scenario probably. |
I do think you have a valid point and I'm OK with closing this PR. I had a
specific use case for it, but it doesn't justify updating this from the
perspective of the product.
…On Sun, Feb 2, 2025 at 20:07 egelhaus ***@***.***> wrote:
Hey, Yes it does make sense to me that the TikTok Editor is better than
ours. It still defeats the Scheduling Putpose, but alright, this will make
sense in a specific Scenario probably.
—
Reply to this email directly, view it on GitHub
<#573 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AF6OPW7ADJ2XDUEIILS5RX32NZUHBAVCNFSM6AAAAABVW2662SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMRZGUYTMOBRGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hey, no this PR can be still opened, I only said that to get the Opinion of you on why this is needed, but it could be used to just upload it one time and then have it on all Platforms including on TikTok, without having to upload it again and just edit it. |
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