diff --git a/CHANGELOG.md b/CHANGELOG.md index ab6220584..00a1b6677 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Features - Autospam Live Filters - block remote activities based on comma separated keywords ([40b45b2a](https://github.com/pixelfed/pixelfed/commit/40b45b2a)) +- Added Software Update banner to admin home feeds ([b0fb1988](https://github.com/pixelfed/pixelfed/commit/b0fb1988)) ### Updated diff --git a/app/Http/Controllers/SoftwareUpdateController.php b/app/Http/Controllers/SoftwareUpdateController.php new file mode 100644 index 000000000..e29359830 --- /dev/null +++ b/app/Http/Controllers/SoftwareUpdateController.php @@ -0,0 +1,21 @@ +middleware('auth'); + $this->middleware('admin'); + } + + public function getSoftwareUpdateCheck(Request $request) + { + $res = SoftwareUpdateService::get(); + return $res; + } +} diff --git a/app/Services/Internal/SoftwareUpdateService.php b/app/Services/Internal/SoftwareUpdateService.php new file mode 100644 index 000000000..40aaf867e --- /dev/null +++ b/app/Services/Internal/SoftwareUpdateService.php @@ -0,0 +1,68 @@ + $curVersion, + 'latest' => [ + 'version' => null, + 'published_at' => null, + 'url' => null, + ], + 'running_latest' => $hideWarning ? true : null + ]; + } + + return [ + 'current' => $curVersion, + 'latest' => [ + 'version' => $versions['latest']['version'], + 'published_at' => $versions['latest']['published_at'], + 'url' => $versions['latest']['url'], + ], + 'running_latest' => strval($versions['latest']['version']) === strval($curVersion) + ]; + } + + public static function fetchLatest() + { + try { + $res = Http::withOptions(['allow_redirects' => false]) + ->timeout(5) + ->connectTimeout(5) + ->retry(2, 500) + ->get('https://versions.pixelfed.org/versions.json'); + } catch (RequestException $e) { + return; + } catch (ConnectionException $e) { + return; + } catch (Exception $e) { + return; + } + + if(!$res->ok()) { + return; + } + + return $res->json(); + } +} diff --git a/config/instance.php b/config/instance.php index 7d5463055..d1566da4a 100644 --- a/config/instance.php +++ b/config/instance.php @@ -140,5 +140,9 @@ return [ 'max_children' => env('INSTANCE_PARENTAL_CONTROLS_MAX_CHILDREN', 1), 'auto_verify_email' => true, ], - ] + ], + + 'software-update' => [ + 'disable_failed_warning' => env('INSTANCE_SOFTWARE_UPDATE_DISABLE_FAILED_WARNING', false) + ], ]; diff --git a/public/js/home.chunk.88eeebf6c53d4dca.js b/public/js/home.chunk.88eeebf6c53d4dca.js new file mode 100644 index 000000000..1f6666262 Binary files /dev/null and b/public/js/home.chunk.88eeebf6c53d4dca.js differ diff --git a/public/js/home.chunk.ada2cbf0ec3271bd.js.LICENSE.txt b/public/js/home.chunk.88eeebf6c53d4dca.js.LICENSE.txt similarity index 100% rename from public/js/home.chunk.ada2cbf0ec3271bd.js.LICENSE.txt rename to public/js/home.chunk.88eeebf6c53d4dca.js.LICENSE.txt diff --git a/public/js/home.chunk.ada2cbf0ec3271bd.js b/public/js/home.chunk.ada2cbf0ec3271bd.js deleted file mode 100644 index 6b898fbc3..000000000 Binary files a/public/js/home.chunk.ada2cbf0ec3271bd.js and /dev/null differ diff --git a/public/js/manifest.js b/public/js/manifest.js index de48f35bf..7e718244d 100644 Binary files a/public/js/manifest.js and b/public/js/manifest.js differ diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 5162e3d96..5a2fbe031 100644 Binary files a/public/mix-manifest.json and b/public/mix-manifest.json differ diff --git a/resources/assets/components/Home.vue b/resources/assets/components/Home.vue index c75ed0a13..dac188281 100644 --- a/resources/assets/components/Home.vue +++ b/resources/assets/components/Home.vue @@ -9,6 +9,48 @@
Update your Pixelfed server as soon as possible!
+Once you update, this message will disappear.
++ Current version: {{ updateInfo?.current ?? 'Unknown' }} + Latest version: {{ updateInfo?.latest?.version ?? 'Unknown' }} +
+We attempted to check if there is a new version available, however we encountered an error. Click here to view the latest releases.
+You can set INSTANCE_SOFTWARE_UPDATE_DISABLE_FAILED_WARNING=true
to remove this warning.
Current version: {{ updateInfo?.current ?? 'Unknown' }}
+