Skip to content

Commit

Permalink
fix(setupchecks): Add setup checks for current checks
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Aug 29, 2024
1 parent 5fbbbea commit ff60f2c
Show file tree
Hide file tree
Showing 6 changed files with 257 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
66 changes: 66 additions & 0 deletions lib/SetupCheck/BackgroundBlurLoading.php
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;

Check failure on line 24 in lib/SetupCheck/BackgroundBlurLoading.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedTrait

lib/SetupCheck/BackgroundBlurLoading.php:24:6: UndefinedTrait: Trait OCA\Settings\SetupChecks\CheckServerResponseTrait does not exist (see https://psalm.dev/023)

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 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'),
);

}
}
48 changes: 48 additions & 0 deletions lib/SetupCheck/FederationLockCache.php
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) {

Check failure on line 40 in lib/SetupCheck/FederationLockCache.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedClass

lib/SetupCheck/FederationLockCache.php:40:67: UndefinedClass: Class, interface or enum named OC\Memcache\NullCache does not exist (see https://psalm.dev/019)
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-memory-cache'),
);
}
}
48 changes: 48 additions & 0 deletions lib/SetupCheck/RecommendCache.php
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 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-memory-cache'),
);
}
}
42 changes: 42 additions & 0 deletions lib/SetupCheck/RecordingBackend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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\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.'));
}
}
42 changes: 42 additions & 0 deletions lib/SetupCheck/SIPConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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\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.'));
}
}

0 comments on commit ff60f2c

Please sign in to comment.