diff options
| author | 2025-10-21 17:49:06 -0400 | |
|---|---|---|
| committer | 2025-10-21 23:49:06 +0200 | |
| commit | eee8b8c03f93b82ed762137e386659d9da3adbf3 (patch) | |
| tree | ff8d78c35a5dabca59f8b105acad0a5e47e307ce /app/Controllers/extensionController.php | |
| parent | 59d33779d1e80ad2bb60b110377a3a18a085f95c (diff) | |
Add support for extension compatibility (#8081)
The compatibility does support only a minimum version of FreshRSS. If we need
something a bit more clever in the future, it is possible to handle a rule
with a bit more complexity.
See https://github.com/FreshRSS/FreshRSS/issues/5903
* Update app/Controllers/extensionController.php
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
* Update app/i18n/pl/admin.php
Co-authored-by: Inverle <inverle@proton.me>
* Minor move phpstan-type
---------
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Co-authored-by: Inverle <inverle@proton.me>
Diffstat (limited to 'app/Controllers/extensionController.php')
| -rw-r--r-- | app/Controllers/extensionController.php | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.php index 39b5e858a..c0e85edbc 100644 --- a/app/Controllers/extensionController.php +++ b/app/Controllers/extensionController.php @@ -3,6 +3,8 @@ declare(strict_types=1); /** * The controller to manage extensions. + * + * @phpstan-type ExtensionFullMetadata array{name:string,entrypoint:string,author:string,description:string,version:string,type:'system'|'user',url:string,method:string,directory:string,compatibility:string} */ class FreshRSS_extension_Controller extends FreshRSS_ActionController { /** @@ -40,7 +42,7 @@ class FreshRSS_extension_Controller extends FreshRSS_ActionController { /** * Fetch extension list from GitHub - * @return list<array{name:string,author:string,description:string,version:string,entrypoint:string,type:'system'|'user',url:string,method:string,directory:string}> + * @phpstan-return list<ExtensionFullMetadata> */ protected function getAvailableExtensionList(): array { $extensionListUrl = 'https://raw.githubusercontent.com/FreshRSS/Extensions/master/extensions.json'; @@ -82,7 +84,10 @@ class FreshRSS_extension_Controller extends FreshRSS_ActionController { if (isset($extension['version']) && is_numeric($extension['version'])) { $extension['version'] = (string)$extension['version']; } - $keys = ['author', 'description', 'directory', 'entrypoint', 'method', 'name', 'type', 'url', 'version']; + if (!array_key_exists('compatibility', $extension)) { + $extension['compatibility'] = '✔'; + } + $keys = ['author', 'description', 'directory', 'entrypoint', 'method', 'name', 'type', 'url', 'version', 'compatibility']; $extension = array_intersect_key($extension, array_flip($keys)); // Keep only valid keys $extension = array_filter($extension, 'is_string'); foreach ($keys as $key) { @@ -93,10 +98,16 @@ class FreshRSS_extension_Controller extends FreshRSS_ActionController { if (!in_array($extension['type'], ['system', 'user'], true) || trim($extension['name']) === '') { continue; } - /** @var array{name:string,author:string,description:string,version:string,entrypoint:string,type:'system'|'user',url:string,method:string,directory:string} $extension */ + /** @var ExtensionFullMetadata $extension */ $extensions[] = $extension; } - return $extensions; + + return array_map(static function (array $extension) { + if ($extension['compatibility'] !== '✔') { + $extension['compatibility'] = version_compare($extension['compatibility'], FRESHRSS_VERSION, '>=') ? '✔' : '✘'; + } + return $extension; + }, $extensions); } /** |
