mirror of
https://github.com/p-stream/backend.git
synced 2026-04-05 22:29:44 +00:00
Fix for Watch-history PUT masks 400
This commit is contained in:
parent
8e8fd83164
commit
cd6704eafb
1 changed files with 10 additions and 9 deletions
|
|
@ -52,16 +52,17 @@ export default defineEventHandler(async event => {
|
|||
}
|
||||
|
||||
if (method === 'PUT') {
|
||||
try {
|
||||
const body = await readBody(event);
|
||||
const body = await readBody(event);
|
||||
|
||||
// Accept single object (normal playback) or array (e.g. user import)
|
||||
const bodySchema = z.union([
|
||||
watchHistoryItemSchema,
|
||||
z.array(watchHistoryItemSchema).max(1000),
|
||||
]);
|
||||
const parsed = bodySchema.parse(body);
|
||||
const items = Array.isArray(parsed) ? parsed : [parsed];
|
||||
// Accept single object (normal playback) or array (e.g. user import)
|
||||
const bodySchema = z.union([
|
||||
watchHistoryItemSchema,
|
||||
z.array(watchHistoryItemSchema).max(1000),
|
||||
]);
|
||||
const parsed = bodySchema.parse(body);
|
||||
const items = Array.isArray(parsed) ? parsed : [parsed];
|
||||
|
||||
try {
|
||||
|
||||
const upsertPromises = items.map(validatedBody => {
|
||||
const itemTmdbId = items.length === 1 ? tmdbId : (validatedBody.tmdbId ?? tmdbId);
|
||||
|
|
|
|||
Loading…
Reference in a new issue