Files
aigen/server/api/library/still-groups.post.ts
T

12 lines
583 B
TypeScript

export default defineEventHandler(async (event) => {
const { owner } = assertLibraryOwner(event)
const body = await readBody(event)
if (!Array.isArray(body?.ids) || !body.ids.length || body.ids.length > 1000 || body.ids.some((id: unknown) => typeof id !== 'string')) {
throw createError({ statusCode: 400, statusMessage: 'Select images to group' })
}
const ids = [...new Set<string>(body.ids)]
for (const id of ids) assertFolderAccess(event, getStill(owner, id).folderId)
await groupLibraryStills(owner, ids, body.ungroup === true)
return publicLibrary(event)
})