-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(setupchecks): Add setup checks for current checks
Signed-off-by: Joas Schilling <[email protected]>
- Loading branch information
1 parent
b7eb5b2
commit 16642b2
Showing
10 changed files
with
332 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
namespace OCA\Talk\SetupCheck; | ||
|
||
use OCA\Settings\SetupChecks\CheckServerResponseTrait; | ||
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 WASM URLs works | ||
*/ | ||
class BackgroundBlurLoading 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 'talk'; | ||
} | ||
|
||
public function getName(): string { | ||
return $this->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'), | ||
); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Talk\SetupCheck; | ||
|
||
use OC\Memcache\NullCache; | ||
use OCA\Talk\Config; | ||
use OCP\ICacheFactory; | ||
use OCP\IL10N; | ||
use OCP\IURLGenerator; | ||
use OCP\SetupCheck\ISetupCheck; | ||
use OCP\SetupCheck\SetupResult; | ||
|
||
class FederationLockCache implements ISetupCheck { | ||
public function __construct( | ||
readonly protected Config $talkConfig, | ||
readonly protected ICacheFactory $cacheFactory, | ||
readonly protected IURLGenerator $urlGenerator, | ||
readonly protected IL10N $l, | ||
) { | ||
} | ||
|
||
public function getCategory(): string { | ||
return 'talk'; | ||
} | ||
|
||
public function getName(): string { | ||
return $this->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'), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Talk\SetupCheck; | ||
|
||
use OCA\Talk\Config; | ||
use OCP\ICacheFactory; | ||
use OCP\IL10N; | ||
use OCP\IURLGenerator; | ||
use OCP\SetupCheck\ISetupCheck; | ||
use OCP\SetupCheck\SetupResult; | ||
|
||
class RecommendCache implements ISetupCheck { | ||
public function __construct( | ||
readonly protected Config $talkConfig, | ||
readonly protected ICacheFactory $cacheFactory, | ||
readonly protected IURLGenerator $urlGenerator, | ||
readonly protected IL10N $l, | ||
) { | ||
} | ||
|
||
public function getCategory(): string { | ||
return 'talk'; | ||
} | ||
|
||
public function getName(): string { | ||
return $this->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'), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Talk\SetupCheck; | ||
|
||
use OCA\Talk\Config; | ||
use OCP\IL10N; | ||
use OCP\SetupCheck\ISetupCheck; | ||
use OCP\SetupCheck\SetupResult; | ||
|
||
class RecordingBackend implements ISetupCheck { | ||
public function __construct( | ||
readonly protected Config $talkConfig, | ||
readonly protected IL10N $l, | ||
) { | ||
} | ||
|
||
public function getCategory(): string { | ||
return 'talk'; | ||
} | ||
|
||
public function getName(): string { | ||
return $this->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.')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Talk\SetupCheck; | ||
|
||
use OCA\Talk\Config; | ||
use OCP\IL10N; | ||
use OCP\SetupCheck\ISetupCheck; | ||
use OCP\SetupCheck\SetupResult; | ||
|
||
class SIPConfiguration implements ISetupCheck { | ||
public function __construct( | ||
readonly protected Config $talkConfig, | ||
readonly protected IL10N $l, | ||
) { | ||
} | ||
|
||
public function getCategory(): string { | ||
return 'talk'; | ||
} | ||
|
||
public function getName(): string { | ||
return $this->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.')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc. | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
namespace OC\Memcache { | ||
|
||
use OCP\IMemcache; | ||
|
||
class NullCache implements IMemcache { | ||
public function add($key, $value, $ttl = 0) { | ||
} | ||
|
||
public function inc($key, $step = 1) { | ||
} | ||
|
||
public function dec($key, $step = 1) { | ||
} | ||
|
||
public function cas($key, $old, $new) { | ||
} | ||
|
||
public function cad($key, $old) { | ||
} | ||
|
||
public function ncad(string $key, mixed $old): bool { | ||
} | ||
} | ||
|
||
class ArrayCache implements IMemcache { | ||
public function add($key, $value, $ttl = 0) { | ||
} | ||
|
||
public function inc($key, $step = 1) { | ||
} | ||
|
||
public function dec($key, $step = 1) { | ||
} | ||
|
||
public function cas($key, $old, $new) { | ||
} | ||
|
||
public function cad($key, $old) { | ||
} | ||
|
||
public function ncad(string $key, mixed $old): bool { | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/stubs/oca_settings_setupchecks_checkserverresponsetrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
namespace OCA\Settings\SetupChecks { | ||
use Generator; | ||
|
||
trait CheckServerResponseTrait { | ||
protected function serverConfigHelp(): string { | ||
} | ||
} | ||
|
||
trait CheckServerResponseTrait2 { | ||
protected function serverConfigHelp(): string { | ||
} | ||
|
||
protected function runHEAD(string $url, bool $ignoreSSL = true, bool $httpErrors = true): Generator { | ||
} | ||
|
||
protected function runRequest(string $method, string $url, array $options = []): Generator { | ||
} | ||
} | ||
} |