From 709b1bb91e436a1e43e1a48f50c8535c65dcffed Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Mon, 12 Jan 2026 11:36:55 +0100 Subject: [PATCH] fix(TextToImage): Refactor scheduling mechanism --- core/Controller/TextToImageApiController.php | 6 ++++++ lib/public/TextToImage/Task.php | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/core/Controller/TextToImageApiController.php b/core/Controller/TextToImageApiController.php index d9d86129c2b98..346284c219143 100644 --- a/core/Controller/TextToImageApiController.php +++ b/core/Controller/TextToImageApiController.php @@ -96,6 +96,12 @@ public function schedule(string $input, string $appId, string $identifier = '', if (strlen($input) > 64_000) { return new DataResponse(['message' => $this->l->t('Input text is too long')], Http::STATUS_PRECONDITION_FAILED); } + if ($numberOfImages > 12) { + return new DataResponse(['message' => $this->l->t('Cannot generate more than 12 images')], Http::STATUS_PRECONDITION_FAILED); + } + if ($numberOfImages < 1) { + return new DataResponse(['message' => $this->l->t('Cannot generate less than 1 image')], Http::STATUS_PRECONDITION_FAILED); + } $task = new Task($input, $appId, $numberOfImages, $this->userId, $identifier); try { try { diff --git a/lib/public/TextToImage/Task.php b/lib/public/TextToImage/Task.php index e610af6aa9610..cee8e614f0308 100644 --- a/lib/public/TextToImage/Task.php +++ b/lib/public/TextToImage/Task.php @@ -83,6 +83,12 @@ final public function __construct( protected ?string $userId, protected ?string $identifier = '', ) { + if ($this->numberOfImages > 12) { + throw new \ValueError('Cannot generate more than 12 images'); + } + if ($this->numberOfImages < 1) { + throw new \ValueError('Cannot generate less than 1 image'); + } } /**