feat: conditionally queue AniList updates and use updated payload

This commit is contained in:
2025-12-17 07:51:19 -05:00
parent 3c5685dbdb
commit b26d22ad91

View File

@@ -87,8 +87,6 @@ app.openapi(route, async (c) => {
titleId,
isRetrying = false,
} = await c.req.json<typeof UpdateWatchStatusRequest._type>();
const aniListToken = c.req.header("X-AniList-Token");
// Check if we should use mock data
const { useMockData } = await import("~/libs/useMockData");
if (useMockData()) {
@@ -106,16 +104,21 @@ app.openapi(route, async (c) => {
}
}
const aniListToken = c.req.header("X-AniList-Token");
if (aniListToken) {
await queueTask(
"ANILIST_UPDATES",
{
deviceId,
watchStatus,
[AnilistUpdateType.UpdateWatchStatus]: {
aniListToken,
titleId,
watchStatus,
},
updateType: AnilistUpdateType.UpdateWatchStatus,
},
{ req: c.req, scheduleConfig: { delay: { minute: 1 } } },
);
}
return c.json(SuccessResponse, { status: 200 });
});