Skip to content

Commit

Permalink
feat(tiktok): update conetnt posting method based on setting
Browse files Browse the repository at this point in the history
  • Loading branch information
keiwanmosaddegh committed Jan 23, 2025
1 parent 912895b commit 81eacbe
Showing 1 changed file with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,27 +226,39 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
): 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/video/init/',
`https://open.tiktokapis.com/v2/post/publish${endpoint}`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
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!,
Expand Down

0 comments on commit 81eacbe

Please sign in to comment.