feat: conditionally queue AniList updates and use updated payload
This commit is contained in:
@@ -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 });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user