From 0af11e2c9186120090bc3fc388c2e96c51212b03 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Mon, 12 Jan 2026 13:21:09 +0100 Subject: [PATCH 1/3] fix(TaskProcessing): Refactor TextToImage fallback Signed-off-by: Marcel Klehr --- lib/private/TaskProcessing/Manager.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php index afaa723c20039..1516f2bf02b97 100644 --- a/lib/private/TaskProcessing/Manager.php +++ b/lib/private/TaskProcessing/Manager.php @@ -291,13 +291,18 @@ private function _getTextToImageProviders(): array { $oldProviders = $this->textToImageManager->getProviders(); $newProviders = []; foreach ($oldProviders as $oldProvider) { - $newProvider = new class($oldProvider, $this->appData) implements IProvider, ISynchronousProvider { + $newProvider = new class($oldProvider, $this->appData, $this->l10nFactory, $this->userManager) implements IProvider, ISynchronousProvider { private \OCP\TextToImage\IProvider $provider; private IAppData $appData; + private IFactory $l10nFactory; - public function __construct(\OCP\TextToImage\IProvider $provider, IAppData $appData) { + private IUserManager $userManager; + + public function __construct(\OCP\TextToImage\IProvider $provider, IAppData $appData, IFactory $l10nFactory, IUserManager $userManager) { $this->provider = $provider; $this->appData = $appData; + $this->l10nFactory = $l10nFactory; + $this->userManager = $userManager; } public function getId(): string { @@ -330,6 +335,21 @@ public function process(?string $userId, array $input, callable $reportProgress) } catch (\OCP\Files\NotFoundException) { $folder = $this->appData->newFolder('text2image'); } + if ($input['numberOfImages'] > 12) { + throw new UserFacingProcessingException( + 'numberOfImages cannot be greater than 12', + userFacingMessage: + $this->l10nFactory->get('core', $this->l10nFactory->getUserLanguage($this->userManager->get($userId))) + ->t('Cannot generate more than 12 images') + ); + } + if ($input['numberOfImages'] < 1) { + throw new UserFacingProcessingException( + 'numberOfImages must be greater than 0', + userFacingMessage: + $this->l10nFactory->get('core', $this->l10nFactory->getUserLanguage($this->userManager->get($userId))) + ->t('Cannot generate less than 1 image')); + } $resources = []; $files = []; for ($i = 0; $i < $input['numberOfImages']; $i++) { From c0a35cc002ab27632c51bc05ad0219c87277e10a Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Tue, 3 Feb 2026 09:17:32 +0100 Subject: [PATCH 2/3] Fix: Run cs:fix --- lib/private/TaskProcessing/Manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php index 1516f2bf02b97..b7c696fe77885 100644 --- a/lib/private/TaskProcessing/Manager.php +++ b/lib/private/TaskProcessing/Manager.php @@ -340,7 +340,7 @@ public function process(?string $userId, array $input, callable $reportProgress) 'numberOfImages cannot be greater than 12', userFacingMessage: $this->l10nFactory->get('core', $this->l10nFactory->getUserLanguage($this->userManager->get($userId))) - ->t('Cannot generate more than 12 images') + ->t('Cannot generate more than 12 images') ); } if ($input['numberOfImages'] < 1) { From 743edf3337acf2ea2b413095051cefbaf0ee55f6 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Thu, 5 Feb 2026 17:31:17 +0100 Subject: [PATCH 3/3] fix: Use ProcessingException instead of UserFacingProcessing Exception which is not in nc < 33 Signed-off-by: Marcel Klehr --- lib/private/TaskProcessing/Manager.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php index b7c696fe77885..da9adb2f4a974 100644 --- a/lib/private/TaskProcessing/Manager.php +++ b/lib/private/TaskProcessing/Manager.php @@ -336,19 +336,14 @@ public function process(?string $userId, array $input, callable $reportProgress) $folder = $this->appData->newFolder('text2image'); } if ($input['numberOfImages'] > 12) { - throw new UserFacingProcessingException( - 'numberOfImages cannot be greater than 12', - userFacingMessage: - $this->l10nFactory->get('core', $this->l10nFactory->getUserLanguage($this->userManager->get($userId))) - ->t('Cannot generate more than 12 images') + throw new ProcessingException( + 'numberOfImages cannot be greater than 12' ); } if ($input['numberOfImages'] < 1) { - throw new UserFacingProcessingException( - 'numberOfImages must be greater than 0', - userFacingMessage: - $this->l10nFactory->get('core', $this->l10nFactory->getUserLanguage($this->userManager->get($userId))) - ->t('Cannot generate less than 1 image')); + throw new ProcessingException( + 'numberOfImages must be greater than 0' + ); } $resources = []; $files = [];