fix: task for anilist-updates not encoding body in base 64
This commit is contained in:
@@ -132,6 +132,7 @@ app.openapi(route, async (c) => {
|
|||||||
watchStatus,
|
watchStatus,
|
||||||
titleId,
|
titleId,
|
||||||
isRetrying: true,
|
isRetrying: true,
|
||||||
|
nameSuffix: "watch-status",
|
||||||
},
|
},
|
||||||
{ req: c.req, scheduleConfig: { delay: { minute: 1 } } },
|
{ req: c.req, scheduleConfig: { delay: { minute: 1 } } },
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ export function buildNewEpisodeTaskId(aniListId: number) {
|
|||||||
return `${aniListId}`;
|
return `${aniListId}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildAnilistRetryTaskId(deviceId: string, titleId: number) {
|
export function buildAnilistRetryTaskId(
|
||||||
return `${deviceId}-${titleId}`;
|
deviceId: string,
|
||||||
|
titleId: number,
|
||||||
|
nameSuffix: string,
|
||||||
|
) {
|
||||||
|
return `${deviceId}-${titleId}-${nameSuffix}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ type QueueBody = {
|
|||||||
watchStatus: WatchStatus | null;
|
watchStatus: WatchStatus | null;
|
||||||
titleId: number;
|
titleId: number;
|
||||||
isRetrying: true;
|
isRetrying: true;
|
||||||
|
nameSuffix: string;
|
||||||
};
|
};
|
||||||
"new-episode": { aniListId: number; episodeNumber: number };
|
"new-episode": { aniListId: number; episodeNumber: number };
|
||||||
};
|
};
|
||||||
@@ -178,8 +179,9 @@ function buildTask(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
case "anilist-updates":
|
case "anilist-updates":
|
||||||
const { deviceId, titleId } = body as QueueBody[typeof queueName];
|
const { deviceId, titleId, nameSuffix } =
|
||||||
taskId = buildAnilistRetryTaskId(deviceId, titleId);
|
body as QueueBody[typeof queueName];
|
||||||
|
taskId = buildAnilistRetryTaskId(deviceId, titleId, nameSuffix);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: `projects/${projectId}/locations/northamerica-northeast1/queues/${queueName}/tasks/${taskId}`,
|
name: `projects/${projectId}/locations/northamerica-northeast1/queues/${queueName}/tasks/${taskId}`,
|
||||||
@@ -187,7 +189,9 @@ function buildTask(
|
|||||||
httpRequest: {
|
httpRequest: {
|
||||||
url: `${domain}/watch-status`,
|
url: `${domain}/watch-status`,
|
||||||
httpMethod: "POST",
|
httpMethod: "POST",
|
||||||
body: JSON.stringify(body),
|
body: Buffer.from(
|
||||||
|
JSON.stringify({ ...body, nameSuffix: undefined }),
|
||||||
|
).toString("base64"),
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"X-Anilist-Token": headers?.["X-Anilist-Token"],
|
"X-Anilist-Token": headers?.["X-Anilist-Token"],
|
||||||
|
|||||||
Reference in New Issue
Block a user