diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php index 9b91131c..e003ff84 100644 --- a/lib/Controller/LocalController.php +++ b/lib/Controller/LocalController.php @@ -701,9 +701,10 @@ class LocalController extends Controller { $actor = $this->cacheActorService->getFromId($id); if ($actor->gotIcon()) { $avatar = $actor->getIcon(); - $document = $this->documentService->getFromCache($avatar->getId()); + $document = $this->documentService->getFromCache($avatar->getId(), $mime); - $response = new FileDisplayResponse($document); + $response = + new FileDisplayResponse($document, Http::STATUS_OK, ['Content-Type' => $mime]); $response->cacheFor(86400); return $response; diff --git a/lib/Controller/NavigationController.php b/lib/Controller/NavigationController.php index b9b256a0..b613fb1e 100644 --- a/lib/Controller/NavigationController.php +++ b/lib/Controller/NavigationController.php @@ -291,9 +291,11 @@ class NavigationController extends Controller { */ public function documentGet(string $id): Response { try { - $file = $this->documentService->getFromCache($id); + $mime = ''; + $file = $this->documentService->getFromCache($id, $mime); + + return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $mime]); - return new FileDisplayResponse($file, Http::STATUS_OK); } catch (Exception $e) { return $this->fail($e); } @@ -311,9 +313,10 @@ class NavigationController extends Controller { public function documentGetPublic(string $id): Response { try { - $file = $this->documentService->getFromCache($id, true); + $mime = ''; + $file = $this->documentService->getFromCache($id, $mime, true); - return new FileDisplayResponse($file); + return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $mime]); } catch (Exception $e) { return $this->fail($e); } @@ -331,9 +334,10 @@ class NavigationController extends Controller { public function resizedGet(string $id): Response { try { - $file = $this->documentService->getResizedFromCache($id); + $mime = ''; + $file = $this->documentService->getResizedFromCache($id, $mime); - return new FileDisplayResponse($file); + return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $mime]); } catch (Exception $e) { return $this->fail($e); } @@ -351,12 +355,14 @@ class NavigationController extends Controller { public function resizedGetPublic(string $id): Response { try { - $file = $this->documentService->getResizedFromCache($id, true); + $mime = ''; + $file = $this->documentService->getResizedFromCache($id, $mime, true); - return new FileDisplayResponse($file); + return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $mime]); } catch (Exception $e) { return $this->fail($e); } } } + diff --git a/lib/Service/CacheDocumentService.php b/lib/Service/CacheDocumentService.php index 78505637..b147c8f6 100644 --- a/lib/Service/CacheDocumentService.php +++ b/lib/Service/CacheDocumentService.php @@ -61,8 +61,8 @@ class CacheDocumentService { use TStringTools; - const RESIZED_HEIGHT = 250; - const RESIZED_WIDTH = 350; + const RESIZED_WIDTH = 280; + const RESIZED_HEIGHT = 180; /** @var IAppData */ private $appData; diff --git a/lib/Service/DocumentService.php b/lib/Service/DocumentService.php index d9630955..c5318bc3 100644 --- a/lib/Service/DocumentService.php +++ b/lib/Service/DocumentService.php @@ -190,6 +190,7 @@ class DocumentService { /** * @param string $id + * @param string $mime * @param bool $public * * @return ISimpleFile @@ -199,8 +200,9 @@ class DocumentService { * @throws RequestResultNotJsonException * @throws SocialAppConfigException */ - public function getResizedFromCache(string $id, bool $public = false) { + public function getResizedFromCache(string $id, string &$mime = '', bool $public = false) { $document = $this->cacheRemoteDocument($id, $public); + $mime = $document->getMimeType(); return $this->cacheService->getContentFromCache($document->getResizedCopy()); } @@ -218,7 +220,7 @@ class DocumentService { * @throws RequestResultNotJsonException * @throws SocialAppConfigException */ - public function getFromCache(string $id, bool $public = false, string &$mimeType = '') { + public function getFromCache(string $id, string &$mimeType = '', bool $public = false) { $document = $this->cacheRemoteDocument($id, $public); $mimeType = $document->getMimeType();