From 415aa6fb4f83cf73714af93a5140bd6b3eb3fdc6 Mon Sep 17 00:00:00 2001 From: MB-Finski Date: Tue, 30 Jan 2024 12:23:32 +0000 Subject: [PATCH] More psalm fixes Signed-off-by: MB-Finski --- .../Text2Image/Text2ImageHelperService.php | 52 +------------------ 1 file changed, 2 insertions(+), 50 deletions(-) diff --git a/lib/Service/Text2Image/Text2ImageHelperService.php b/lib/Service/Text2Image/Text2ImageHelperService.php index 3e534f48..f2612f80 100644 --- a/lib/Service/Text2Image/Text2ImageHelperService.php +++ b/lib/Service/Text2Image/Text2ImageHelperService.php @@ -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]; } @@ -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); } /** @@ -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 = ''; - foreach ($links as $link) { - $body .= 'image'; - $body .= '
'; - } - $body .= ''; - return [ - 'body' => $body, - 'headers' => [ - 'Content-Type' => ['text/html'], - ], - ]; - } }