-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add setup checks and verify WOPI connectivity
Signed-off-by: Julius Knorr <[email protected]>
- Loading branch information
1 parent
20e836c
commit 1564b81
Showing
10 changed files
with
227 additions
and
47 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
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
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,68 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
namespace OCA\Richdocuments\SetupCheck; | ||
|
||
use OCA\Richdocuments\Service\CapabilitiesService; | ||
use OCP\Http\Client\IClientService; | ||
use OCP\IL10N; | ||
use OCP\IURLGenerator; | ||
use OCP\SetupCheck\ISetupCheck; | ||
use OCP\SetupCheck\SetupResult; | ||
use Psr\Log\LoggerInterface; | ||
|
||
class CollaboraUpdate implements ISetupCheck { | ||
|
||
public function __construct( | ||
protected IL10N $l10n, | ||
protected CapabilitiesService $capabilitiesService, | ||
protected IURLGenerator $urlGenerator, | ||
protected IClientService $clientService, | ||
protected LoggerInterface $logger, | ||
) { | ||
} | ||
|
||
public function getCategory(): string { | ||
return 'office'; | ||
} | ||
|
||
public function getName(): string { | ||
return $this->l10n->t('Collabora server version check'); | ||
} | ||
|
||
public function run(): SetupResult { | ||
$client = $this->clientService->newClient(); | ||
|
||
$url = null; | ||
if ($this->capabilitiesService->isCode()) { | ||
$url = 'https://rating.collaboraonline.com/UpdateCheck'; | ||
} | ||
|
||
if ($this->capabilitiesService->isEnterprise()) { | ||
$url = 'https://rating.collaboraonline.com/UpdateCheck?product=cool'; | ||
} | ||
|
||
if ($url === null) { | ||
return SetupResult::success(); | ||
} | ||
|
||
// FIXME internet conection check config | ||
|
||
$response = $client->get($url, ['timeout' => 5]); | ||
$response = json_decode($response->getBody(), true); | ||
$latestVersion = $response['coolwsd_version'] ?? null; | ||
|
||
$installedVersion = $this->capabilitiesService->getProductVersion(); | ||
|
||
if ($latestVersion !== null && version_compare($latestVersion, $installedVersion, '>')) { | ||
return SetupResult::warning($this->l10n->t('Collabora server version is out of date. Currently using %s, new version is available: %s', [$installedVersion, $latestVersion])); | ||
} | ||
|
||
return SetupResult::success(); | ||
} | ||
} |
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: 2025 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
namespace OCA\Richdocuments\SetupCheck; | ||
|
||
use OCA\Richdocuments\Service\ConnectivityService; | ||
use OCP\Http\Client\IClientService; | ||
use OCP\IL10N; | ||
use OCP\IURLGenerator; | ||
use OCP\SetupCheck\ISetupCheck; | ||
use OCP\SetupCheck\SetupResult; | ||
use Psr\Log\LoggerInterface; | ||
|
||
class ConnectivityCheck implements ISetupCheck { | ||
|
||
public function __construct( | ||
protected IL10N $l10n, | ||
protected ConnectivityService $connectivityService, | ||
protected IURLGenerator $urlGenerator, | ||
protected IClientService $clientService, | ||
protected LoggerInterface $logger, | ||
) { | ||
} | ||
|
||
public function getCategory(): string { | ||
return 'office'; | ||
} | ||
|
||
public function getName(): string { | ||
return $this->l10n->t('Collabora server connectivity check'); | ||
} | ||
|
||
public function run(): SetupResult { | ||
try { | ||
$this->connectivityService->test(); | ||
} catch (\Exception $e) { | ||
return SetupResult::error($this->l10n->t('Collabora is not configured properly:') . ' ' . $e->getMessage()); | ||
} | ||
|
||
return SetupResult::success(); | ||
} | ||
} |
Oops, something went wrong.