Skip to content

Commit 35a9b1c

Browse files
committed
feat: tiktok access token fix
1 parent d4300a1 commit 35a9b1c

File tree

1 file changed

+42
-49
lines changed

1 file changed

+42
-49
lines changed

libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts

Lines changed: 42 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -222,58 +222,51 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
222222
postDetails: PostDetails<TikTokDto>[],
223223
integration: Integration
224224
): Promise<PostResponse[]> {
225-
try {
226-
const [firstPost, ...comments] = postDetails;
225+
const [firstPost, ...comments] = postDetails;
227226

228-
const {
229-
data: { publish_id },
230-
} = await (
231-
await this.fetch(
232-
'https://open.tiktokapis.com/v2/post/publish/video/init/',
233-
{
234-
method: 'POST',
235-
headers: {
236-
'Content-Type': 'application/json; charset=UTF-8',
237-
Authorization: `Bearer ${accessToken}`,
227+
const {
228+
data: { publish_id },
229+
} = await (
230+
await this.fetch(
231+
'https://open.tiktokapis.com/v2/post/publish/video/init/',
232+
{
233+
method: 'POST',
234+
headers: {
235+
'Content-Type': 'application/json; charset=UTF-8',
236+
Authorization: `Bearer ${accessToken}`,
237+
},
238+
body: JSON.stringify({
239+
post_info: {
240+
title: firstPost.message,
241+
privacy_level: firstPost.settings.privacy_level,
242+
disable_duet: !firstPost.settings.duet,
243+
disable_comment: !firstPost.settings.comment,
244+
disable_stitch: !firstPost.settings.stitch,
245+
brand_content_toggle: firstPost.settings.brand_content_toggle,
246+
brand_organic_toggle: firstPost.settings.brand_organic_toggle,
238247
},
239-
body: JSON.stringify({
240-
post_info: {
241-
title: firstPost.message,
242-
privacy_level: firstPost.settings.privacy_level,
243-
disable_duet: !firstPost.settings.duet,
244-
disable_comment: !firstPost.settings.comment,
245-
disable_stitch: !firstPost.settings.stitch,
246-
brand_content_toggle: firstPost.settings.brand_content_toggle,
247-
brand_organic_toggle: firstPost.settings.brand_organic_toggle,
248-
},
249-
source_info: {
250-
source: 'PULL_FROM_URL',
251-
video_url: firstPost?.media?.[0]?.url!,
252-
},
253-
}),
254-
}
255-
)
256-
).json();
248+
source_info: {
249+
source: 'PULL_FROM_URL',
250+
video_url: firstPost?.media?.[0]?.url!,
251+
},
252+
}),
253+
}
254+
)
255+
).json();
257256

258-
const { url, id: videoId } = await this.uploadedVideoSuccess(
259-
integration.profile!,
260-
publish_id,
261-
accessToken
262-
);
257+
const { url, id: videoId } = await this.uploadedVideoSuccess(
258+
integration.profile!,
259+
publish_id,
260+
accessToken
261+
);
263262

264-
return [
265-
{
266-
id: firstPost.id,
267-
releaseURL: url,
268-
postId: String(videoId),
269-
status: 'success',
270-
},
271-
];
272-
} catch (err) {
273-
throw new BadBody('titok-error', JSON.stringify(err), {
274-
// @ts-ignore
275-
postDetails,
276-
});
277-
}
263+
return [
264+
{
265+
id: firstPost.id,
266+
releaseURL: url,
267+
postId: String(videoId),
268+
status: 'success',
269+
},
270+
];
278271
}
279272
}

0 commit comments

Comments
 (0)