Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ You can also edit your documents off-line with the Collabora Office app from the
<nextcloud min-version="28" max-version="28"/>
</dependencies>
<background-jobs>
<job>OCA\Richdocuments\Backgroundjobs\ObtainCapabilities</job>
<job>OCA\Richdocuments\Backgroundjobs\CheckConnectivity</job>
<job>OCA\Richdocuments\Backgroundjobs\Cleanup</job>
</background-jobs>
<commands>
Expand Down
6 changes: 4 additions & 2 deletions composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
'OCA\\Richdocuments\\AppConfig' => $baseDir . '/../lib/AppConfig.php',
'OCA\\Richdocuments\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
'OCA\\Richdocuments\\Backgroundjobs\\CheckConnectivity' => $baseDir . '/../lib/Backgroundjobs/CheckConnectivity.php',
'OCA\\Richdocuments\\Backgroundjobs\\Cleanup' => $baseDir . '/../lib/Backgroundjobs/Cleanup.php',
'OCA\\Richdocuments\\Backgroundjobs\\ObtainCapabilities' => $baseDir . '/../lib/Backgroundjobs/ObtainCapabilities.php',
'OCA\\Richdocuments\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
'OCA\\Richdocuments\\Command\\ActivateConfig' => $baseDir . '/../lib/Command/ActivateConfig.php',
'OCA\\Richdocuments\\Command\\ConvertToBigInt' => $baseDir . '/../lib/Command/ConvertToBigInt.php',
Expand Down Expand Up @@ -59,8 +59,11 @@
'OCA\\Richdocuments\\Preview\\OpenDocument' => $baseDir . '/../lib/Preview/OpenDocument.php',
'OCA\\Richdocuments\\Preview\\Pdf' => $baseDir . '/../lib/Preview/Pdf.php',
'OCA\\Richdocuments\\Reference\\OfficeTargetReferenceProvider' => $baseDir . '/../lib/Reference/OfficeTargetReferenceProvider.php',
'OCA\\Richdocuments\\Service\\BaseRemoteService' => $baseDir . '/../lib/Service/BaseRemoteService.php',
'OCA\\Richdocuments\\Service\\CapabilitiesService' => $baseDir . '/../lib/Service/CapabilitiesService.php',
'OCA\\Richdocuments\\Service\\ConnectivityService' => $baseDir . '/../lib/Service/ConnectivityService.php',
'OCA\\Richdocuments\\Service\\DemoService' => $baseDir . '/../lib/Service/DemoService.php',
'OCA\\Richdocuments\\Service\\DiscoveryService' => $baseDir . '/../lib/Service/DiscoveryService.php',
'OCA\\Richdocuments\\Service\\FederationService' => $baseDir . '/../lib/Service/FederationService.php',
'OCA\\Richdocuments\\Service\\FileTargetService' => $baseDir . '/../lib/Service/FileTargetService.php',
'OCA\\Richdocuments\\Service\\FontService' => $baseDir . '/../lib/Service/FontService.php',
Expand All @@ -74,6 +77,5 @@
'OCA\\Richdocuments\\Template\\CollaboraTemplateProvider' => $baseDir . '/../lib/Template/CollaboraTemplateProvider.php',
'OCA\\Richdocuments\\TokenManager' => $baseDir . '/../lib/TokenManager.php',
'OCA\\Richdocuments\\UploadException' => $baseDir . '/../lib/UploadException.php',
'OCA\\Richdocuments\\WOPI\\DiscoveryManager' => $baseDir . '/../lib/WOPI/DiscoveryManager.php',
'OCA\\Richdocuments\\WOPI\\Parser' => $baseDir . '/../lib/WOPI/Parser.php',
);
6 changes: 4 additions & 2 deletions composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class ComposerStaticInitRichdocuments
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
'OCA\\Richdocuments\\AppConfig' => __DIR__ . '/..' . '/../lib/AppConfig.php',
'OCA\\Richdocuments\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
'OCA\\Richdocuments\\Backgroundjobs\\CheckConnectivity' => __DIR__ . '/..' . '/../lib/Backgroundjobs/CheckConnectivity.php',
'OCA\\Richdocuments\\Backgroundjobs\\Cleanup' => __DIR__ . '/..' . '/../lib/Backgroundjobs/Cleanup.php',
'OCA\\Richdocuments\\Backgroundjobs\\ObtainCapabilities' => __DIR__ . '/..' . '/../lib/Backgroundjobs/ObtainCapabilities.php',
'OCA\\Richdocuments\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
'OCA\\Richdocuments\\Command\\ActivateConfig' => __DIR__ . '/..' . '/../lib/Command/ActivateConfig.php',
'OCA\\Richdocuments\\Command\\ConvertToBigInt' => __DIR__ . '/..' . '/../lib/Command/ConvertToBigInt.php',
Expand Down Expand Up @@ -74,8 +74,11 @@ class ComposerStaticInitRichdocuments
'OCA\\Richdocuments\\Preview\\OpenDocument' => __DIR__ . '/..' . '/../lib/Preview/OpenDocument.php',
'OCA\\Richdocuments\\Preview\\Pdf' => __DIR__ . '/..' . '/../lib/Preview/Pdf.php',
'OCA\\Richdocuments\\Reference\\OfficeTargetReferenceProvider' => __DIR__ . '/..' . '/../lib/Reference/OfficeTargetReferenceProvider.php',
'OCA\\Richdocuments\\Service\\BaseRemoteService' => __DIR__ . '/..' . '/../lib/Service/BaseRemoteService.php',
'OCA\\Richdocuments\\Service\\CapabilitiesService' => __DIR__ . '/..' . '/../lib/Service/CapabilitiesService.php',
'OCA\\Richdocuments\\Service\\ConnectivityService' => __DIR__ . '/..' . '/../lib/Service/ConnectivityService.php',
'OCA\\Richdocuments\\Service\\DemoService' => __DIR__ . '/..' . '/../lib/Service/DemoService.php',
'OCA\\Richdocuments\\Service\\DiscoveryService' => __DIR__ . '/..' . '/../lib/Service/DiscoveryService.php',
'OCA\\Richdocuments\\Service\\FederationService' => __DIR__ . '/..' . '/../lib/Service/FederationService.php',
'OCA\\Richdocuments\\Service\\FileTargetService' => __DIR__ . '/..' . '/../lib/Service/FileTargetService.php',
'OCA\\Richdocuments\\Service\\FontService' => __DIR__ . '/..' . '/../lib/Service/FontService.php',
Expand All @@ -89,7 +92,6 @@ class ComposerStaticInitRichdocuments
'OCA\\Richdocuments\\Template\\CollaboraTemplateProvider' => __DIR__ . '/..' . '/../lib/Template/CollaboraTemplateProvider.php',
'OCA\\Richdocuments\\TokenManager' => __DIR__ . '/..' . '/../lib/TokenManager.php',
'OCA\\Richdocuments\\UploadException' => __DIR__ . '/..' . '/../lib/UploadException.php',
'OCA\\Richdocuments\\WOPI\\DiscoveryManager' => __DIR__ . '/..' . '/../lib/WOPI/DiscoveryManager.php',
'OCA\\Richdocuments\\WOPI\\Parser' => __DIR__ . '/..' . '/../lib/WOPI/Parser.php',
);

Expand Down
33 changes: 31 additions & 2 deletions cypress/e2e/settings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,31 @@ const collaboraUrl = Cypress.env('collaboraUrl')

describe('Office admin settings', function() {

let randUser

before(function() {
cy.createRandomUser().then(user => {
randUser = user
cy.login(user)
cy.uploadFile(user, 'document.odt', 'application/vnd.oasis.opendocument.text', '/document.odt')
})
})

beforeEach(function() {
cy.login(randUser)
})

beforeEach(function() {
cy.login(new User('admin', 'admin'))
cy.visit('/settings/admin/richdocuments')
cy.intercept({
method: 'POST',
url: '/index.php/apps/richdocuments/ajax/admin.php',
}).as('updateSettings')
cy.intercept({
method: 'GET',
url: collaboraUrl + '/**',
}).as('officeServer')
})

it('Error for invalid url', function() {
Expand All @@ -45,11 +63,21 @@ describe('Office admin settings', function() {
.clear()
.type((usesHttps ? 'https' : 'http') + '://invalid.example.com{enter}')
cy.wait('@updateSettings').its('response.statusCode').should('equal', 500)
cy.get('#security-warning-state-failure .message')
cy.get('.notecard').first()
.scrollIntoView()
.should('be.visible')
.should('contain.text', 'Could not establish connection to the Collabora Online server.')
cy.screenshot()

cy.login(randUser)
cy.visit('/apps/files', {
onBeforeLoad(win) {
cy.spy(win, 'postMessage').as('postMessage')
},
})
cy.openFile('document.odt')
cy.waitForViewer()
cy.waitForCollabora()
})

it('Opens settings and configure a valid url', function() {
Expand All @@ -64,7 +92,8 @@ describe('Office admin settings', function() {
.clear()
.type(collaboraUrl + '{enter}')
cy.wait('@updateSettings').its('response.statusCode').should('equal', 200)
cy.get('#security-warning-state-ok .message')
cy.wait('@officeServer').its('response.statusCode').should('equal', 200)
cy.get('.notecard').first()
.scrollIntoView()
.should('be.visible')
.should('contain.text', 'Collabora Online server is reachable.')
Expand Down
4 changes: 2 additions & 2 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
use OCA\Richdocuments\Preview\Pdf;
use OCA\Richdocuments\Reference\OfficeTargetReferenceProvider;
use OCA\Richdocuments\Service\CapabilitiesService;
use OCA\Richdocuments\Service\DiscoveryService;
use OCA\Richdocuments\Template\CollaboraTemplateProvider;
use OCA\Richdocuments\WOPI\DiscoveryManager;
use OCA\Viewer\Event\LoadViewer;
use OCP\App\IAppManager;
use OCP\AppFramework\App;
Expand Down Expand Up @@ -215,7 +215,7 @@ public function checkAndEnableCODEServer() {
$appConfig->setAppValue('wopi_url', $new_wopi_url);
$appConfig->setAppValue('disable_certificate_verification', 'yes');

$discoveryManager = $this->getContainer()->get(DiscoveryManager::class);
$discoveryManager = $this->getContainer()->get(DiscoveryService::class);
$capabilitiesService = $this->getContainer()->get(CapabilitiesService::class);

$discoveryManager->refetch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@

namespace OCA\Richdocuments\Backgroundjobs;

use OC\BackgroundJob\TimedJob;
use OCA\Richdocuments\Service\CapabilitiesService;

class ObtainCapabilities extends TimedJob {
/** @var CapabilitiesService */
private $capabilitiesService;

public function __construct(CapabilitiesService $capabilitiesService) {
$this->capabilitiesService = $capabilitiesService;
use OCA\Richdocuments\Service\ConnectivityService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;

class CheckConnectivity extends TimedJob {
public function __construct(
protected ITimeFactory $timeFactory,
protected ConnectivityService $connectivityService
) {
parent::__construct($timeFactory);
$this->setInterval(60 * 60);
}

protected function run($argument) {
$this->capabilitiesService->refetch();
$this->connectivityService->verifyConnection();
}
}
1 change: 0 additions & 1 deletion lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ public function getCapabilities() {
'use_groups' => $this->config->getAppValue('use_groups'),
'doc_format' => $this->config->getAppValue('doc_format'),
'timeout' => $this->config->getAppValue('timeout'),

]
],
];
Expand Down
42 changes: 12 additions & 30 deletions lib/Command/ActivateConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,19 @@
namespace OCA\Richdocuments\Command;

use OCA\Richdocuments\AppConfig;
use OCA\Richdocuments\Service\CapabilitiesService;
use OCA\Richdocuments\WOPI\DiscoveryManager;
use OCA\Richdocuments\Service\ConnectivityService;
use OCA\Richdocuments\WOPI\Parser;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class ActivateConfig extends Command {
/** @var AppConfig */
private $appConfig;

/** @var CapabilitiesService */
private $capabilitiesService;

/** @var DiscoveryManager */
private $discoveryManager;

/** @var Parser */
private $wopiParser;

public function __construct(AppConfig $appConfig, CapabilitiesService $capabilitiesService, DiscoveryManager $discoveryManager, Parser $wopiParser) {
public function __construct(
private AppConfig $appConfig,
private ConnectivityService $connectivityService,
private Parser $wopiParser
) {
parent::__construct();

$this->appConfig = $appConfig;
$this->capabilitiesService = $capabilitiesService;
$this->discoveryManager = $discoveryManager;
$this->wopiParser = $wopiParser;
}

protected function configure() {
Expand All @@ -62,17 +48,13 @@ protected function configure() {

protected function execute(InputInterface $input, OutputInterface $output) {
try {
$this->discoveryManager->refetch();
$this->capabilitiesService->clear();
$capaUrlSrc = $this->wopiParser->getUrlSrc('Capabilities');
if (is_array($capaUrlSrc) && $capaUrlSrc['action'] === 'getinfo') {
$public_wopi_url = str_replace('/hosting/capabilities', '', $capaUrlSrc['urlsrc']);
if ($public_wopi_url !== null) {
$this->appConfig->setAppValue('public_wopi_url', $public_wopi_url);
}
$this->connectivityService->verifyConnection(true);
$publicUrl = $this->wopiParser->getDetectedPublicUrl();
if ($publicUrl) {
$this->appConfig->setAppValue('public_wopi_url', $publicUrl);
$this->connectivityService->verifyConnection(true);

}
$this->capabilitiesService->clear();
$this->capabilitiesService->refetch();
$output->writeln('<info>Activated any config changes</info>');
return 0;
} catch (\Exception $e) {
Expand Down
Loading