Merge pull request #58015 from nextcloud/fix/text-to-image-scheduling

fix(TextToImage): Refactor scheduling mechanism
This commit is contained in:
Andy Scherzinger 2026-02-05 15:53:37 +01:00 committed by GitHub
commit 428e7b4adb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -81,6 +81,12 @@ class TextToImageApiController extends OCSController {
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 {

View file

@ -68,6 +68,12 @@ final class Task implements \JsonSerializable {
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');
}
}
/**