Skip to content

Commit

Permalink
Merge pull request #49044 from nextcloud/backport/48912/stable30
Browse files Browse the repository at this point in the history
  • Loading branch information
Altahrim authored Nov 4, 2024
2 parents 0319e50 + 849b205 commit b1759e9
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 3 deletions.
10 changes: 8 additions & 2 deletions apps/settings/lib/Controller/AppSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,15 @@ private function fetchApps() {
$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]);
$appScreenshot = $app['screenshot'][0] ?? null;
if (is_array($appScreenshot)) {
// Screenshot with thumbnail
$appScreenshot = $appScreenshot['@value'];
}

$app['screenshot'] = $this->createProxyPreviewUrl($appScreenshot);
}
$this->allApps[$app['id']] = $app;
}
Expand Down
11 changes: 11 additions & 0 deletions lib/private/App/InfoParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@ public function parse($file) {
$array['dependencies']['backend'] = [$array['dependencies']['backend']];
}

// Ensure some fields are always arrays
if (isset($array['screenshot']) && !is_array($array['screenshot'])) {
$array['screenshot'] = [$array['screenshot']];
}
if (isset($array['author']) && !is_array($array['author'])) {
$array['author'] = [$array['author']];
}
if (isset($array['category']) && !is_array($array['category'])) {
$array['category'] = [$array['category']];
}

if ($this->cache !== null) {
$this->cache->set($fileCacheKey, json_encode($array));
}
Expand Down
4 changes: 3 additions & 1 deletion tests/data/app/expected-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"name": "Server-side Encryption",
"description": "\n\tThis application encrypts all files accessed by ownCloud at rest, wherever they are stored. As an example, with this application enabled, external cloud based Amazon S3 storage will be encrypted, protecting this data on storage outside of the control of the Admin. When this application is enabled for the first time, all files are encrypted as users log in and are prompted for their password. The recommended recovery key option enables recovery of files in case the key is lost. \n\tNote that this app encrypts all files that are touched by ownCloud, so external storage providers and applications such as SharePoint will see new files encrypted when they are accessed. Encryption is based on AES 128 or 256 bit keys. More information is available in the Encryption documentation \n\t",
"licence": "AGPL",
"author": "Sam Tuke, Bjoern Schiessle, Florin Peter",
"author": [
"Sam Tuke, Bjoern Schiessle, Florin Peter"
],
"requiremin": "4",
"shipped": "true",
"documentation": {
Expand Down
50 changes: 50 additions & 0 deletions tests/data/app/various-single-item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"id": "notifications",
"name": "Notifications",
"description": "A single screenshot should be an array",
"version": "1.0.0",
"licence": "agpl",
"author": [
"Joas Schilling"
],
"dependencies": {
"nextcloud": {
"@attributes": {
"min-version": "16",
"max-version": "16"
}
},
"backend": []
},
"screenshot": [
"https://raw.githubusercontent.com/nextcloud/notifications/refs/heads/master/docs/screenshot.png"
],
"category": [
"monitoring"
],
"info": [],
"background-jobs": [],
"activity": {
"filters": [],
"settings": [],
"providers": []
},
"commands": [],
"remote": [],
"public": [],
"repair-steps": {
"install": [],
"pre-migration": [],
"post-migration": [],
"live-migration": [],
"uninstall": []
},
"settings": {
"admin": [],
"admin-section": [],
"personal": [],
"personal-section": []
},
"two-factor-providers": [],
"types": []
}
2 changes: 2 additions & 0 deletions tests/data/app/various-single-item.json.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
SPDX-License-Identifier: AGPL-3.0-or-later
22 changes: 22 additions & 0 deletions tests/data/app/various-single-item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!--
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
<id>notifications</id>
<name>Notifications</name>
<description>A single screenshot should be an array</description>
<version>1.0.0</version>
<licence>agpl</licence>
<author>Joas Schilling</author>

<category>monitoring</category>

<screenshot>https://raw.githubusercontent.com/nextcloud/notifications/refs/heads/master/docs/screenshot.png</screenshot>

<dependencies>
<nextcloud min-version="16" max-version="16"/>
</dependencies>
</info>
1 change: 1 addition & 0 deletions tests/lib/App/InfoParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function providesInfoXml(): array {
[null, 'invalid-info.xml'],
['navigation-one-item.json', 'navigation-one-item.xml'],
['navigation-two-items.json', 'navigation-two-items.xml'],
['various-single-item.json', 'various-single-item.xml'],
];
}
}

0 comments on commit b1759e9

Please sign in to comment.