fix(upload): correct tiktok creator request

This commit is contained in:
2026-08-02 18:33:00 +07:00 Unverified
parent 24f14e9342
commit 4f29e6f76f
2 changed files with 35 additions and 7 deletions
+20 -5
View File
@@ -243,10 +243,20 @@ async function publishTiktok(upload: typeof videoUploads.$inferSelect) {
const settings = upload.tiktokSettings as TiktokSettings;
const creatorResponse = await fetch(
"https://open.tiktokapis.com/v2/post/publish/creator_info/query/",
{ headers: { Authorization: `Bearer ${token}` } },
{
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json; charset=UTF-8",
},
},
);
if (!creatorResponse.ok)
throw new Error("TikTok creator information lookup failed.");
if (!creatorResponse.ok) {
const detail = await creatorResponse.text().catch(() => "");
throw new Error(
`TikTok creator information lookup failed (${creatorResponse.status})${detail ? `: ${detail}` : "."}`,
);
}
const creator = (await creatorResponse.json()) as {
data?: { privacy_level_options?: string[] };
};
@@ -367,8 +377,13 @@ export async function processDueVideoUploads() {
where: (table, { eq, and, ne }) =>
and(eq(table.uploadId, upload.id), ne(table.status, "completed")),
});
for (const job of jobs)
await publishVideoJob(job.id).catch(() => undefined);
for (const job of jobs) {
await publishVideoJob(job.id).catch((error) => {
const message =
error instanceof Error ? error.message : "Platform upload failed.";
console.error(`[${job.platform}] ${job.id}: ${message}`);
});
}
const remaining = await db.query.videoUploadJobs.findMany({
where: (table, { eq, and, ne }) =>
and(eq(table.uploadId, upload.id), ne(table.status, "completed")),