mirror of
https://github.com/nextcloud/server.git
synced 2026-03-06 07:21:11 -05:00
fix(TaskProcessing): Refactor TextToImage fallback
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
parent
f86202cafe
commit
a33349921e
1 changed files with 22 additions and 2 deletions
|
|
@ -307,13 +307,18 @@ class Manager implements IManager {
|
|||
$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 {
|
||||
|
|
@ -346,6 +351,21 @@ class Manager implements IManager {
|
|||
} 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++) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue