]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(app-store): Also proxy images of locally installed apps
authorFerdinand Thiessen <opensource@fthiessen.de>
Wed, 23 Oct 2024 10:54:25 +0000 (12:54 +0200)
committerFerdinand Thiessen <opensource@fthiessen.de>
Wed, 23 Oct 2024 11:02:06 +0000 (13:02 +0200)
Before this only app store apps got their screenshots proxied,
but this will cause locally installed apps to not be correctly shown on the app-store.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
apps/settings/lib/Controller/AppSettingsController.php

index 2fbebe3f607145520dea6c0858c4c1c13e7c41e9..9622b66a16526bfc212be006185f82aef8aab743 100644 (file)
@@ -230,11 +230,25 @@ class AppSettingsController extends Controller {
                ], $categories);
        }
 
+       /**
+        * Convert URL to proxied URL so CSP is no problem
+        */
+       private function createProxyPreviewUrl(string $url): string {
+               if ($url === '') {
+                       return '';
+               }
+               return 'https://usercontent.apps.nextcloud.com/' . base64_encode($url);
+       }
+
        private function fetchApps() {
                $appClass = new \OC_App();
                $apps = $appClass->listAllApps();
                foreach ($apps as $app) {
                        $app['installed'] = true;
+                       // locally installed apps have a flatted screenshot property
+                       if (isset($app['screenshot'][0])) {
+                               $app['screenshot'] = $this->createProxyPreviewUrl($app['screenshot'][0]);
+                       }
                        $this->allApps[$app['id']] = $app;
                }
 
@@ -289,7 +303,7 @@ class AppSettingsController extends Controller {
                $apps = array_map(function (array $appData) use ($dependencyAnalyzer, $ignoreMaxApps) {
                        if (isset($appData['appstoreData'])) {
                                $appstoreData = $appData['appstoreData'];
-                               $appData['screenshot'] = isset($appstoreData['screenshots'][0]['url']) ? 'https://usercontent.apps.nextcloud.com/' . base64_encode($appstoreData['screenshots'][0]['url']) : '';
+                               $appData['screenshot'] = $this->createProxyPreviewUrl($appstoreData['screenshots'][0]['url'] ?? '');
                                $appData['category'] = $appstoreData['categories'];
                                $appData['releases'] = $appstoreData['releases'];
                        }