From 16642b29dbb736ca338d722d66b72428628934c6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 28 Aug 2024 12:49:49 +0200 Subject: [PATCH] fix(setupchecks): Add setup checks for current checks Signed-off-by: Joas Schilling --- lib/AppInfo/Application.php | 11 ++++ lib/SetupCheck/BackgroundBlurLoading.php | 66 +++++++++++++++++++ lib/SetupCheck/FederationLockCache.php | 48 ++++++++++++++ lib/SetupCheck/RecommendCache.php | 47 +++++++++++++ lib/SetupCheck/RecordingBackend.php | 40 +++++++++++ lib/SetupCheck/SIPConfiguration.php | 40 +++++++++++ psalm.xml | 1 + tests/psalm-baseline.xml | 10 +-- tests/stubs/oc_memcache.php | 50 ++++++++++++++ ...s_setupchecks_checkserverresponsetrait.php | 24 +++++++ 10 files changed, 332 insertions(+), 5 deletions(-) create mode 100644 lib/SetupCheck/BackgroundBlurLoading.php create mode 100644 lib/SetupCheck/FederationLockCache.php create mode 100644 lib/SetupCheck/RecommendCache.php create mode 100644 lib/SetupCheck/RecordingBackend.php create mode 100644 lib/SetupCheck/SIPConfiguration.php create mode 100644 tests/stubs/oc_memcache.php create mode 100644 tests/stubs/oca_settings_setupchecks_checkserverresponsetrait.php diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 21fa3b69705..e8fb8025f14 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -107,6 +107,11 @@ use OCA\Talk\Search\UnifiedSearchCSSLoader; use OCA\Talk\Search\UnifiedSearchFilterPlugin; use OCA\Talk\Settings\Personal; +use OCA\Talk\SetupCheck\BackgroundBlurLoading; +use OCA\Talk\SetupCheck\FederationLockCache; +use OCA\Talk\SetupCheck\RecommendCache; +use OCA\Talk\SetupCheck\RecordingBackend; +use OCA\Talk\SetupCheck\SIPConfiguration; use OCA\Talk\Share\Listener as ShareListener; use OCA\Talk\Signaling\Listener as SignalingListener; use OCA\Talk\Status\Listener as StatusListener; @@ -332,6 +337,12 @@ public function register(IRegistrationContext $context): void { $context->registerTalkBackend(TalkBackend::class); $context->registerTeamResourceProvider(TalkTeamResourceProvider::class); + + $context->registerSetupCheck(RecommendCache::class); + $context->registerSetupCheck(FederationLockCache::class); + $context->registerSetupCheck(RecordingBackend::class); + $context->registerSetupCheck(SIPConfiguration::class); + $context->registerSetupCheck(BackgroundBlurLoading::class); } public function boot(IBootContext $context): void { diff --git a/lib/SetupCheck/BackgroundBlurLoading.php b/lib/SetupCheck/BackgroundBlurLoading.php new file mode 100644 index 00000000000..eec9c6de4b2 --- /dev/null +++ b/lib/SetupCheck/BackgroundBlurLoading.php @@ -0,0 +1,66 @@ +l10n->t('Background blur'); + } + + public function run(): SetupResult { + $url = $this->urlGenerator->linkTo('spreed', 'js/tflite.wasm'); + $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 WASM loading support. Please check manually if your web server serves `.wasm` 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 `.wasm` files. This is typically an issue with the Nginx configuration. For background blur it needs an adjustment to also deliver `.wasm` files. Compare your Nginx configuration to the recommended configuration in our documentation.'), + $this->urlGenerator->linkToDocs('admin-nginx'), + ); + + } +} diff --git a/lib/SetupCheck/FederationLockCache.php b/lib/SetupCheck/FederationLockCache.php new file mode 100644 index 00000000000..6f9c2e94cac --- /dev/null +++ b/lib/SetupCheck/FederationLockCache.php @@ -0,0 +1,48 @@ +l->t('Federation'); + } + + public function run(): SetupResult { + if (!$this->talkConfig->isFederationEnabled()) { + return SetupResult::success(); + } + if (!$this->cacheFactory->createLocking('talkroom_') instanceof NullCache) { + return SetupResult::success(); + } + return SetupResult::warning( + $this->l->t('It is highly recommended to configure "memcache.locking" when Talk Federation is enabled.'), + $this->urlGenerator->linkToDocs('admin-cache'), + ); + } +} diff --git a/lib/SetupCheck/RecommendCache.php b/lib/SetupCheck/RecommendCache.php new file mode 100644 index 00000000000..e3f50fe67bf --- /dev/null +++ b/lib/SetupCheck/RecommendCache.php @@ -0,0 +1,47 @@ +l->t('High-performance backend'); + } + + public function run(): SetupResult { + if ($this->talkConfig->getSignalingMode() === Config::SIGNALING_INTERNAL) { + return SetupResult::success(); + } + if ($this->cacheFactory->isAvailable()) { + return SetupResult::success(); + } + return SetupResult::warning( + $this->l->t('It is highly recommended to configure a memory cache when running Nextcloud Talk with a High-performance backend.'), + $this->urlGenerator->linkToDocs('admin-cache'), + ); + } +} diff --git a/lib/SetupCheck/RecordingBackend.php b/lib/SetupCheck/RecordingBackend.php new file mode 100644 index 00000000000..1ae04c31d5b --- /dev/null +++ b/lib/SetupCheck/RecordingBackend.php @@ -0,0 +1,40 @@ +l->t('Recording backend'); + } + + public function run(): SetupResult { + if ($this->talkConfig->getSignalingMode() !== Config::SIGNALING_INTERNAL) { + return SetupResult::success(); + } + if (empty($this->talkConfig->getRecordingServers())) { + return SetupResult::success(); + } + return SetupResult::error($this->l->t('Using the recording backend requires a High-performance backend.')); + } +} diff --git a/lib/SetupCheck/SIPConfiguration.php b/lib/SetupCheck/SIPConfiguration.php new file mode 100644 index 00000000000..a8eba865a4d --- /dev/null +++ b/lib/SetupCheck/SIPConfiguration.php @@ -0,0 +1,40 @@ +l->t('SIP dial-in'); + } + + public function run(): SetupResult { + if ($this->talkConfig->getSignalingMode() !== Config::SIGNALING_INTERNAL) { + return SetupResult::success(); + } + if ($this->talkConfig->getSIPSharedSecret() === '' && $this->talkConfig->getDialInInfo() === '') { + return SetupResult::success(); + } + return SetupResult::error($this->l->t('Using the SIP functionality requires a High-performance backend.')); + } +} diff --git a/psalm.xml b/psalm.xml index 16a43bc40d8..dee49722219 100644 --- a/psalm.xml +++ b/psalm.xml @@ -89,6 +89,7 @@ + diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index cada91c20ba..a7c1418ba42 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -6,11 +6,6 @@ - - - - - @@ -86,6 +81,11 @@ + + + + + getView()]]> diff --git a/tests/stubs/oc_memcache.php b/tests/stubs/oc_memcache.php new file mode 100644 index 00000000000..9b29cf9096a --- /dev/null +++ b/tests/stubs/oc_memcache.php @@ -0,0 +1,50 @@ +