From 262f29f013b847af845f03990703502f3da0f434 Mon Sep 17 00:00:00 2001 From: bruno Date: Tue, 23 Jun 2026 15:15:59 -0400 Subject: [PATCH] =?UTF-8?q?feat:=20endpoint=20PUT=20/api/v1/images/{id}/ta?= =?UTF-8?q?gs=20=E2=80=94=20mise=20=C3=A0=20jour=20manuelle=20des=20tags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Permet au dashboard imagod-web de modifier les tags AI d'une image via PUT /api/v1/images/{id}/tags avec body {"tags": ["tag1", "tag2"]}. Scope requis : images:write --- app/routers/images.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/routers/images.py b/app/routers/images.py index a7e718e..b8333d9 100644 --- a/app/routers/images.py +++ b/app/routers/images.py @@ -444,6 +444,34 @@ async def reprocess_image( return ReprocessResponse(id=image_id) +# ───────────────────────────────────────────────────────────── +# TAGS (mise à jour manuelle) +# ───────────────────────────────────────────────────────────── + +@router.put( + "/{image_id}/tags", + summary="Mettre à jour les tags d'une image", + description="Remplace complètement la liste des tags AI de l'image.", + dependencies=[Depends(require_scope("images:write"))], +) +async def update_tags( + image_id: int, + body: dict, + db: AsyncSession = Depends(get_db), + client: APIClient = Depends(get_current_client), +): + image = await get_image_or_404(image_id, client.id, db) + + tags = body.get("tags", []) + if not isinstance(tags, list) or not all(isinstance(t, str) for t in tags): + raise HTTPException(status_code=400, detail="'tags' doit être une liste de chaînes") + + image.ai_tags = tags + await db.commit() + + return {"updated": True, "id": image_id, "tags": tags} + + # ───────────────────────────────────────────────────────────── # SUPPRESSION # ─────────────────────────────────────────────────────────────