]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix reference preview endpoint when no server-side cache configured 34450/head
authorJulien Veyssier <eneiluj@posteo.net>
Thu, 6 Oct 2022 10:57:38 +0000 (12:57 +0200)
committerJulien Veyssier <julien-nc@posteo.net>
Thu, 13 Oct 2022 13:18:21 +0000 (15:18 +0200)
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
core/Controller/ReferenceController.php

index 591d84f3e7ca5e2c896c09ddf07cf5067e03a89f..a892de03e794573829eed536127e9f9e1d6a0324 100644 (file)
@@ -48,18 +48,21 @@ class ReferenceController extends Controller {
        /**
         * @PublicPage
         * @NoCSRFRequired
+        * @param string $referenceId the reference cache key
+        * @return Response
         */
        public function preview(string $referenceId): Response {
                $reference = $this->referenceManager->getReferenceByCacheKey($referenceId);
-               if ($reference === null) {
-                       return new DataResponse('', Http::STATUS_NOT_FOUND);
-               }
 
                try {
                        $appData = $this->appDataFactory->get('core');
                        $folder = $appData->getFolder('opengraph');
                        $file = $folder->getFile($referenceId);
-                       $response = new DataDownloadResponse($file->getContent(), $referenceId, $reference->getImageContentType());
+                       $response = new DataDownloadResponse(
+                               $file->getContent(),
+                               $referenceId,
+                               $reference === null ? $file->getMimeType() : $reference->getImageContentType()
+                       );
                } catch (NotFoundException|NotPermittedException $e) {
                        $response = new DataResponse('', Http::STATUS_NOT_FOUND);
                }