Skip to content

Commit

Permalink
More psalm fixes
Browse files Browse the repository at this point in the history
Signed-off-by: MB-Finski <[email protected]>
  • Loading branch information
MB-Finski committed Jan 30, 2024
1 parent 9b67447 commit 415aa6f
Showing 1 changed file with 2 additions and 50 deletions.
52 changes: 2 additions & 50 deletions lib/Service/Text2Image/Text2ImageHelperService.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ public function processPrompt(string $prompt, int $nResults, bool $displayPrompt
);

// Save the prompt to database
if ($userId !== null) {
$this->promptMapper->createPrompt($userId, $prompt);
}
$this->promptMapper->createPrompt($userId, $prompt);

return ['url' => $infoUrl, 'reference_url' => $referenceUrl, 'image_gen_id' => $imageGenId, 'prompt' => $prompt];
}
Expand Down Expand Up @@ -177,11 +175,7 @@ private function genIdExists(string $imageGenId): bool {
* @throws \OCP\DB\Exception
*/
public function getPromptHistory(string $userId): array {
if ($userId === null) {
return [];
} else {
return $this->promptMapper->getPromptsOfUser($userId);
}
return $this->promptMapper->getPromptsOfUser($userId);
}

/**
Expand Down Expand Up @@ -581,46 +575,4 @@ public function notifyWhenReady(string $imageGenId, string $userId): void {
$this->assistantService->sendNotification($assistantTask);
}
}

/**
* Get raw image page
*
* @param string $imageGenId
* @return array
* @throws BaseException
*/
public function getRawImagePage(string $imageGenId): array {
$generationInfo = $this->getGenerationInfo($imageGenId, true);

/** @var array $imageFiles */
$imageFiles = $generationInfo['files'];

// Generate a HTML link to each image
/** @var string[] $links */
$links = [];
/** @var array $imageFile */
foreach ($imageFiles as $imageFile) {
$links[] = $this->urlGenerator->linkToRouteAbsolute(
Application::APP_ID . '.Text2Image.getImage',
[
'imageGenId' => $imageGenId,
'fileNameId' => intval($imageFile['id']),
]
);
}

// Create a simple http page in the response:
$body = '<html><body>';
foreach ($links as $link) {
$body .= '<img src="' . $link . '" alt="image">';
$body .= '<br>';
}
$body .= '</body></html>';
return [
'body' => $body,
'headers' => [
'Content-Type' => ['text/html'],
],
];
}
}

0 comments on commit 415aa6f

Please sign in to comment.