Allow the OEM config to be provided as JSON files

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2017-11-20 21:26:50 +01:00
Родитель f7768f0075
Коммит df1d5e5cb4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: FE03C3A163FEDE68
3 изменённых файлов: 49 добавлений и 2 удалений

1
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1 @@
config/*.json

Просмотреть файл

@ -1,3 +1,31 @@
# Nextcloud Client Updater Server # Nextcloud Client Updater Server
This is the Nextcloud client update server. This is the Nextcloud client update server.
## Ship config of other OEMs
Just create a json file in `config/` with the name of the OEM that contains the same entries as the `config.php`.
If the default `config.php` doesn't hold update information for this OEM, the config is read from the JSON file.
```json
{
"linux": {
"version": "2.3.2",
"versionstring": "Nextcloud Client 2.3.2",
"web": "https://nextcloud.com/install/?pk_campaign=clientupdate#install-clients"
},
"win32": {
"version": "2.3.2.1",
"versionstring": "Nextcloud Client 2.3.2 (build 1)",
"downloadUrl": "https://download.nextcloud.com/desktop/releases/Windows/Nextcloud-2.3.2.1-setup.exe",
"web": "https://nextcloud.com/install/?pk_campaign=clientupdate#install-clients"
},
"macos": {
"version": "2.2.4.1",
"versionstring": "Nextcloud Client 2.2.4 (build 1)",
"downloadUrl": "https://download.nextcloud.com/desktop/releases/Mac/Updates/Nextcloud-2.2.4.1.pkg.tbz",
"signature": "MCwCFGC3X/fejC/y/3T2X+c8ldDk7pJGAhQoR8v6vtvvV57nIcMNePA+jNRYcw=="
}
}
```

Просмотреть файл

@ -60,7 +60,25 @@ class Response {
*/ */
private function getUpdateVersion() : array { private function getUpdateVersion() : array {
if(!isset($this->config[$this->oem])) { if(!isset($this->config[$this->oem])) {
return []; if (preg_match('/^[a-zA-Z0-9-_.]+$/', $this->oem) !== 1) {
return [];
}
if (!file_exists(__DIR__ . '/../config/' . $this->oem . '.json')) {
return [];
}
$content = file_get_contents(__DIR__ . '/../config/' . $this->oem . '.json');
if ($content === false) {
return [];
}
$data = json_decode($content, true);
if (!is_array($data)) {
return [];
}
$this->config[$this->oem] = $data;
} }
if(!isset($this->config[$this->oem][$this->platform])) { if(!isset($this->config[$this->oem][$this->platform])) {