fix(upload): correct tiktok creator request
This commit is contained in:
@@ -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")),
|
||||
|
||||
Reference in New Issue
Block a user