Merge pull request #573 from keiwanmosaddegh/main
feat(tiktok): add content posting method alternatives (direct post vs upload)
This commit is contained in:
commit
cffd7e663f
|
|
@ -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 = [
|
const yesNo = [
|
||||||
{
|
{
|
||||||
value: 'true',
|
value: 'true',
|
||||||
|
|
@ -109,12 +120,16 @@ const TikTokSettings: FC<{ values?: any }> = (props) => {
|
||||||
const disclose = watch('disclose');
|
const disclose = watch('disclose');
|
||||||
const brand_organic_toggle = watch('brand_organic_toggle');
|
const brand_organic_toggle = watch('brand_organic_toggle');
|
||||||
const brand_content_toggle = watch('brand_content_toggle');
|
const brand_content_toggle = watch('brand_content_toggle');
|
||||||
|
const content_posting_method = watch('content_posting_method');
|
||||||
|
|
||||||
|
const isUploadMode = content_posting_method === 'UPLOAD';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<CheckTikTokValidity picture={props?.values?.[0]?.image?.[0]?.path} />
|
<CheckTikTokValidity picture={props?.values?.[0]?.image?.[0]?.path} />
|
||||||
<Select
|
<Select
|
||||||
label="Who can see this video?"
|
label="Who can see this video?"
|
||||||
|
disabled={isUploadMode}
|
||||||
{...register('privacy_level', {
|
{...register('privacy_level', {
|
||||||
value: 'PUBLIC_TO_EVERYONE',
|
value: 'PUBLIC_TO_EVERYONE',
|
||||||
})}
|
})}
|
||||||
|
|
@ -126,12 +141,31 @@ const TikTokSettings: FC<{ values?: any }> = (props) => {
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
|
<div className="text-[14px] mb-[10px] text-balance">
|
||||||
|
{`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.`}
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
<hr className="mb-[15px] border-tableBorder" />
|
<hr className="mb-[15px] border-tableBorder" />
|
||||||
<div className="text-[14px] mb-[10px]">Allow User To:</div>
|
<div className="text-[14px] mb-[10px]">Allow User To:</div>
|
||||||
<div className="flex gap-[40px]">
|
<div className="flex gap-[40px]">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
variant="hollow"
|
variant="hollow"
|
||||||
label="Duet"
|
label="Duet"
|
||||||
|
disabled={isUploadMode}
|
||||||
{...register('duet', {
|
{...register('duet', {
|
||||||
value: false,
|
value: false,
|
||||||
})}
|
})}
|
||||||
|
|
@ -139,6 +173,7 @@ const TikTokSettings: FC<{ values?: any }> = (props) => {
|
||||||
<Checkbox
|
<Checkbox
|
||||||
label="Stitch"
|
label="Stitch"
|
||||||
variant="hollow"
|
variant="hollow"
|
||||||
|
disabled={isUploadMode}
|
||||||
{...register('stitch', {
|
{...register('stitch', {
|
||||||
value: false,
|
value: false,
|
||||||
})}
|
})}
|
||||||
|
|
@ -146,6 +181,7 @@ const TikTokSettings: FC<{ values?: any }> = (props) => {
|
||||||
<Checkbox
|
<Checkbox
|
||||||
label="Comments"
|
label="Comments"
|
||||||
variant="hollow"
|
variant="hollow"
|
||||||
|
disabled={isUploadMode}
|
||||||
{...register('comment', {
|
{...register('comment', {
|
||||||
value: false,
|
value: false,
|
||||||
})}
|
})}
|
||||||
|
|
@ -156,6 +192,7 @@ const TikTokSettings: FC<{ values?: any }> = (props) => {
|
||||||
<Checkbox
|
<Checkbox
|
||||||
variant="hollow"
|
variant="hollow"
|
||||||
label="Disclose Video Content"
|
label="Disclose Video Content"
|
||||||
|
disabled={isUploadMode}
|
||||||
{...register('disclose', {
|
{...register('disclose', {
|
||||||
value: false,
|
value: false,
|
||||||
})}
|
})}
|
||||||
|
|
@ -183,7 +220,7 @@ const TikTokSettings: FC<{ values?: any }> = (props) => {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="text-[14px] my-[10px] text-balance">
|
<div className="text-[14px] my-[10px] text-balance">
|
||||||
Turn on to disclose that this video promotes good or services in
|
Turn on to disclose that this video promotes goods or services in
|
||||||
exchange for something of value. You video could promote yourself, a
|
exchange for something of value. You video could promote yourself, a
|
||||||
third party, or both.
|
third party, or both.
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -193,6 +230,7 @@ const TikTokSettings: FC<{ values?: any }> = (props) => {
|
||||||
<Checkbox
|
<Checkbox
|
||||||
variant="hollow"
|
variant="hollow"
|
||||||
label="Your brand"
|
label="Your brand"
|
||||||
|
disabled={isUploadMode}
|
||||||
{...register('brand_organic_toggle', {
|
{...register('brand_organic_toggle', {
|
||||||
value: false,
|
value: false,
|
||||||
})}
|
})}
|
||||||
|
|
@ -205,6 +243,7 @@ const TikTokSettings: FC<{ values?: any }> = (props) => {
|
||||||
<Checkbox
|
<Checkbox
|
||||||
variant="hollow"
|
variant="hollow"
|
||||||
label="Branded content"
|
label="Branded content"
|
||||||
|
disabled={isUploadMode}
|
||||||
{...register('brand_content_toggle', {
|
{...register('brand_content_toggle', {
|
||||||
value: false,
|
value: false,
|
||||||
})}
|
})}
|
||||||
|
|
|
||||||
|
|
@ -32,4 +32,8 @@ export class TikTokDto {
|
||||||
@IsIn(['true'])
|
@IsIn(['true'])
|
||||||
@IsDefined()
|
@IsDefined()
|
||||||
isValidVideo: boolean;
|
isValidVideo: boolean;
|
||||||
|
|
||||||
|
@IsIn(['DIRECT_POST', 'UPLOAD'])
|
||||||
|
@IsString()
|
||||||
|
content_posting_method: 'DIRECT_POST' | 'UPLOAD';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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(
|
async post(
|
||||||
id: string,
|
id: string,
|
||||||
accessToken: string,
|
accessToken: string,
|
||||||
|
|
@ -225,12 +235,11 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
|
||||||
integration: Integration
|
integration: Integration
|
||||||
): Promise<PostResponse[]> {
|
): Promise<PostResponse[]> {
|
||||||
const [firstPost, ...comments] = postDetails;
|
const [firstPost, ...comments] = postDetails;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { publish_id },
|
data: { publish_id },
|
||||||
} = await (
|
} = await (
|
||||||
await this.fetch(
|
await this.fetch(
|
||||||
'https://open.tiktokapis.com/v2/post/publish/video/init/',
|
`https://open.tiktokapis.com/v2/post/publish${this.postingMethod(firstPost.settings.content_posting_method)}`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -238,15 +247,17 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
|
||||||
Authorization: `Bearer ${accessToken}`,
|
Authorization: `Bearer ${accessToken}`,
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
post_info: {
|
...(firstPost.settings.content_posting_method === 'DIRECT_POST' ? {
|
||||||
title: firstPost.message,
|
post_info: {
|
||||||
privacy_level: firstPost.settings.privacy_level,
|
title: firstPost.message,
|
||||||
disable_duet: !firstPost.settings.duet,
|
privacy_level: firstPost.settings.privacy_level,
|
||||||
disable_comment: !firstPost.settings.comment,
|
disable_duet: !firstPost.settings.duet,
|
||||||
disable_stitch: !firstPost.settings.stitch,
|
disable_comment: !firstPost.settings.comment,
|
||||||
brand_content_toggle: firstPost.settings.brand_content_toggle,
|
disable_stitch: !firstPost.settings.stitch,
|
||||||
brand_organic_toggle: firstPost.settings.brand_organic_toggle,
|
brand_content_toggle: firstPost.settings.brand_content_toggle,
|
||||||
},
|
brand_organic_toggle: firstPost.settings.brand_organic_toggle,
|
||||||
|
}
|
||||||
|
} : {}),
|
||||||
source_info: {
|
source_info: {
|
||||||
source: 'PULL_FROM_URL',
|
source: 'PULL_FROM_URL',
|
||||||
video_url: firstPost?.media?.[0]?.url!,
|
video_url: firstPost?.media?.[0]?.url!,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue