From b7f659671e904997fe568d3d33b2c2ad8a822237 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 | 48 +++++++++++++++++ lib/SetupCheck/RecordingBackend.php | 42 +++++++++++++++ lib/SetupCheck/SIPConfiguration.php | 42 +++++++++++++++ 6 files changed, 257 insertions(+) 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 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..42345c1bd1e --- /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 webserver 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..d946ec36c92 --- /dev/null +++ b/lib/SetupCheck/RecommendCache.php @@ -0,0 +1,48 @@ +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..8239035833c --- /dev/null +++ b/lib/SetupCheck/RecordingBackend.php @@ -0,0 +1,42 @@ +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..06a309312f5 --- /dev/null +++ b/lib/SetupCheck/SIPConfiguration.php @@ -0,0 +1,42 @@ +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.')); + } +}