diff options
| author | 2024-10-20 14:51:49 -0400 | |
|---|---|---|
| committer | 2024-10-20 20:51:49 +0200 | |
| commit | ad2c6e6fbf3658f08295fb437a0f97e10498eb11 (patch) | |
| tree | 2207fef4ee921450ac3b25d217711fe16173b6a0 /app/Controllers/extensionController.php | |
| parent | a766ebfb68298cfd2a268d87443c5e2586e93243 (diff) | |
Add privacy settings on extension list retrieval (#4603)
* Add privacy settings on extension list retrieval
There is a new privacy page to handle all configuration related to privacy. At
the moment, only privacy related to extensions can be configured.
The new settings allow to change the location of the extension list file and to
choose if the selected file is cached for a day or retrieved for each request.
Fix #4570
* Update code to pass PHPStan
* make fix-all
---------
Co-authored-by: maTh <math-home@web.de>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'app/Controllers/extensionController.php')
| -rw-r--r-- | app/Controllers/extensionController.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.php index bf1f01c59..42538153d 100644 --- a/app/Controllers/extensionController.php +++ b/app/Controllers/extensionController.php @@ -44,7 +44,18 @@ class FreshRSS_extension_Controller extends FreshRSS_ActionController { */ protected function getAvailableExtensionList(): array { $extensionListUrl = 'https://raw.githubusercontent.com/FreshRSS/Extensions/master/extensions.json'; - $json = httpGet($extensionListUrl, CACHE_PATH . '/extension_list.json', 'json'); + + $cacheFile = CACHE_PATH . '/extension_list.json'; + if (FreshRSS_Context::userConf()->retrieve_extension_list === true) { + if (!file_exists($cacheFile) || (time() - (filemtime($cacheFile) ?: 0) > 86400)) { + $json = httpGet($extensionListUrl, $cacheFile, 'json'); + } else { + $json = @file_get_contents($cacheFile) ?: ''; + } + } else { + Minz_Log::warning('The extension list retrieval is disabled in privacy configuration'); + return []; + } // we ran into problems, simply ignore them if ($json === '') { |
