]> source.dussan.org Git - nextcloud-server.git/commitdiff
Proxy images through usercontent.apps.nextcloud.com
authorLukas Reschke <lukas@statuscode.ch>
Mon, 31 Oct 2016 16:08:11 +0000 (17:08 +0100)
committerLukas Reschke <lukas@statuscode.ch>
Mon, 31 Oct 2016 16:17:47 +0000 (17:17 +0100)
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
settings/Controller/AppSettingsController.php
settings/js/apps.js
tests/Settings/Controller/AppSettingsControllerTest.php

index 1222b6bc86dee6f95d1ea69dfc9e2c8b3413600f..8164dd1fcfa80cbcea48b56254361e5d469d3c5a 100644 (file)
@@ -113,7 +113,7 @@ class AppSettingsController extends Controller {
 
                $templateResponse = new TemplateResponse($this->appName, 'apps', $params, 'user');
                $policy = new ContentSecurityPolicy();
-               $policy->addAllowedImageDomain('*');
+               $policy->addAllowedImageDomain('https://usercontent.apps.nextcloud.com');
                $templateResponse->setContentSecurityPolicy($policy);
 
                return $templateResponse;
@@ -234,18 +234,19 @@ class AppSettingsController extends Controller {
                                'missingMaxOwnCloudVersion' => false,
                                'missingMinOwnCloudVersion' => false,
                                'canInstall' => true,
-                               'preview' => $app['screenshots'][0]['url'],
+                               'preview' => isset($app['screenshots'][0]['url']) ? 'https://usercontent.apps.nextcloud.com/'.base64_encode($app['screenshots'][0]['url']) : '',
                                'score' => $app['ratingOverall'],
                                'removable' => $existsLocally,
                                'active' => $this->appManager->isEnabledForUser($app['id']),
                                'needsDownload' => !$existsLocally,
                                'groups' => $groups,
+                               'fromAppStore' => true,
                        ];
 
 
                        $appFetcher = \OC::$server->getAppFetcher();
                        $newVersion = \OC\Installer::isUpdateAvailable($app['id'], $appFetcher);
-                       if($newVersion) {
+                       if($newVersion && $this->appManager->isInstalled($app['id'])) {
                                $formattedApps[count($formattedApps)-1]['update'] = $newVersion;
                        }
                }
index ecd7543c8ce94a1bc2855d50e57b3e70ab2a1d93..654756af5314e4d006836f7d7aa3c330798f36e6 100644 (file)
@@ -207,7 +207,7 @@ OC.Settings.Apps = OC.Settings.Apps || {
 
                        currentImage.onload = function() {
                                page.find('.app-image')
-                                       .append(OC.Settings.Apps.imageUrl(app.preview, app.detailpage))
+                                       .append(OC.Settings.Apps.imageUrl(app.preview, app.fromAppStore))
                                        .fadeIn();
                        };
                }
@@ -244,7 +244,7 @@ OC.Settings.Apps = OC.Settings.Apps || {
                var img = '<svg width="72" height="72" viewBox="0 0 72 72">';
 
                if (appfromstore) {
-                       img += '<image x="0" y="0" width="72" height="72" preserveAspectRatio="xMinYMin meet" xlink:href="' + url  + '?v=' + oc_config.version + '"  class="app-icon" /></svg>';
+                       img += '<image x="0" y="0" width="72" height="72" preserveAspectRatio="xMinYMin meet" xlink:href="' + url  + '"  class="app-icon" /></svg>';
                } else {
                        img += '<image x="0" y="0" width="72" height="72" preserveAspectRatio="xMinYMin meet" filter="url(#invertIcon)" xlink:href="' + url + '?v=' + oc_config.version + '" class="app-icon"></image></svg>';
                }
index 72fcf1bd7fcb8b36d848fa40bb775c4912be58f0..a3e4a6fd8285f3de484f0b6447c90a78a385af6a 100644 (file)
@@ -28,13 +28,11 @@ use OC\Settings\Controller\AppSettingsController;
 use OCP\AppFramework\Http\ContentSecurityPolicy;
 use OCP\AppFramework\Http\JSONResponse;
 use OCP\AppFramework\Http\TemplateResponse;
-use OCP\ICacheFactory;
 use OCP\L10N\IFactory;
 use Test\TestCase;
 use OCP\IRequest;
 use OCP\IL10N;
 use OCP\IConfig;
-use OCP\ICache;
 use OCP\INavigationManager;
 use OCP\App\IAppManager;
 
@@ -52,8 +50,6 @@ class AppSettingsControllerTest extends TestCase {
        private $l10n;
        /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
        private $config;
-       /** @var ICache|\PHPUnit_Framework_MockObject_MockObject */
-       private $cache;
        /** @var INavigationManager|\PHPUnit_Framework_MockObject_MockObject */
        private $navigationManager;
        /** @var IAppManager|\PHPUnit_Framework_MockObject_MockObject */
@@ -74,13 +70,6 @@ class AppSettingsControllerTest extends TestCase {
                        ->method('t')
                        ->will($this->returnArgument(0));
                $this->config = $this->createMock(IConfig::class);
-               $cacheFactory = $this->createMock(ICacheFactory::class);
-               $this->cache = $this->createMock(ICache::class);
-               $cacheFactory
-                       ->expects($this->once())
-                       ->method('create')
-                       ->with('settings')
-                       ->will($this->returnValue($this->cache));
                $this->navigationManager = $this->createMock(INavigationManager::class);
                $this->appManager = $this->createMock(IAppManager::class);
                $this->categoryFetcher = $this->createMock(CategoryFetcher::class);
@@ -92,7 +81,6 @@ class AppSettingsControllerTest extends TestCase {
                        $this->request,
                        $this->l10n,
                        $this->config,
-                       $cacheFactory,
                        $this->navigationManager,
                        $this->appManager,
                        $this->categoryFetcher,
@@ -185,7 +173,7 @@ class AppSettingsControllerTest extends TestCase {
                        ->with('core_apps');
 
                $policy = new ContentSecurityPolicy();
-               $policy->addAllowedImageDomain('*');
+               $policy->addAllowedImageDomain('https://usercontent.apps.nextcloud.com');
 
                $expected = new TemplateResponse('settings', 'apps', ['category' => 'enabled', 'appstoreEnabled' => true], 'user');
                $expected->setContentSecurityPolicy($policy);
@@ -205,7 +193,7 @@ class AppSettingsControllerTest extends TestCase {
                        ->with('core_apps');
 
                $policy = new ContentSecurityPolicy();
-               $policy->addAllowedImageDomain('*');
+               $policy->addAllowedImageDomain('https://usercontent.apps.nextcloud.com');
 
                $expected = new TemplateResponse('settings', 'apps', ['category' => 'enabled', 'appstoreEnabled' => false], 'user');
                $expected->setContentSecurityPolicy($policy);