Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions lib/private/TaskProcessing/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,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 {
Expand Down Expand Up @@ -346,6 +351,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++) {
Expand Down
Loading