aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/lib/SetupChecks
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-02-15 02:08:04 +0100
committerFerdinand Thiessen <opensource@fthiessen.de>2024-02-15 02:17:20 +0100
commit398b042af79f3be8e65a1f142c362da4318fdf7c (patch)
treee85f9702f94adedd60530a8843ab4363cc45dc42 /apps/settings/lib/SetupChecks
parent096d66edc856be66d4c89c034e31f5b3b9170fd2 (diff)
downloadnextcloud-server-398b042af79f3be8e65a1f142c362da4318fdf7c.tar.gz
nextcloud-server-398b042af79f3be8e65a1f142c362da4318fdf7c.zip
enh(settings): Migrate WOFF2 loading check to a SetupCheck
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/settings/lib/SetupChecks')
-rw-r--r--apps/settings/lib/SetupChecks/Woff2Loading.php82
1 files changed, 82 insertions, 0 deletions
diff --git a/apps/settings/lib/SetupChecks/Woff2Loading.php b/apps/settings/lib/SetupChecks/Woff2Loading.php
new file mode 100644
index 00000000000..d54cbc908ef
--- /dev/null
+++ b/apps/settings/lib/SetupChecks/Woff2Loading.php
@@ -0,0 +1,82 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2024 Ferdinand Thiessen <opensource@fthiessen.de>
+ *
+ * @author Ferdinand Thiessen <opensource@fthiessen.de>
+ *
+ * @license AGPL-3.0-or-later
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OCA\Settings\SetupChecks;
+
+use OCP\Http\Client\IClientService;
+use OCP\IConfig;
+use OCP\IL10N;
+use OCP\IURLGenerator;
+use OCP\SetupCheck\ISetupCheck;
+use OCP\SetupCheck\SetupResult;
+use Psr\Log\LoggerInterface;
+
+/**
+ * Check whether the WOFF2 URLs works
+ */
+class Woff2Loading implements ISetupCheck {
+ use CheckServerResponseTrait;
+
+ public function __construct(
+ protected IL10N $l10n,
+ protected IConfig $config,
+ protected IURLGenerator $urlGenerator,
+ protected IClientService $clientService,
+ protected LoggerInterface $logger,
+ ) {
+ }
+
+ public function getCategory(): string {
+ return 'network';
+ }
+
+ public function getName(): string {
+ return $this->l10n->t('WOFF2 file loading');
+ }
+
+ public function run(): SetupResult {
+ $url = $this->urlGenerator->linkTo('', 'core/fonts/NotoSans-Regular-latin.woff2');
+ $noResponse = true;
+ $responses = $this->runHEAD($url);
+ foreach ($responses as $response) {
+ $noResponse = false;
+ if ($response->getStatusCode() === 200) {
+ return SetupResult::success();
+ }
+ }
+
+ if ($noResponse) {
+ return SetupResult::info(
+ $this->l10n->t('Could not check for WOFF2 loading support. Please check manually if your webserver serves `.woff2` files.') . "\n" . $this->serverConfigHelp(),
+ $this->urlGenerator->linkToDocs('admin-nginx'),
+ );
+ }
+ return SetupResult::warning(
+ $this->l10n->t('Your web server is not properly set up to deliver .woff2 files. This is typically an issue with the Nginx configuration. For Nextcloud 15 it needs an adjustement to also deliver .woff2 files. Compare your Nginx configuration to the recommended configuration in our documentation.'),
+ $this->urlGenerator->linkToDocs('admin-nginx'),
+ );
+
+ }
+}