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