From eee8b8c03f93b82ed762137e386659d9da3adbf3 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Tue, 21 Oct 2025 17:49:06 -0400 Subject: 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 * Update app/i18n/pl/admin.php Co-authored-by: Inverle * Minor move phpstan-type --------- Co-authored-by: Alexandre Alapetite Co-authored-by: Inverle --- app/Controllers/extensionController.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'app/Controllers') 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 + * @phpstan-return list */ 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); } /** -- cgit v1.2.3