From 40f63c11bde445da298072b9811ba7a02434b705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 1 Sep 2023 00:03:09 +0200 Subject: [PATCH] fix: Cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Controller/DocumentController.php | 6 ++++- lib/Service/InitialStateService.php | 34 +++++++++------------------ 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/lib/Controller/DocumentController.php b/lib/Controller/DocumentController.php index ff64cdac98..750604660c 100644 --- a/lib/Controller/DocumentController.php +++ b/lib/Controller/DocumentController.php @@ -428,7 +428,7 @@ private function getFileForUser(int $fileId, string $path = null): File { * @throws NotFoundException * @throws NotPermittedException */ - private function getFileForShare(IShare $share, int $fileId, ?string $path = null): File { + private function getFileForShare(IShare $share, ?int $fileId, ?string $path = null): File { // not authenticated ? if ($share->getPassword()) { if (!$this->session->exists('public_link_authenticated') @@ -447,6 +447,10 @@ private function getFileForShare(IShare $share, int $fileId, ?string $path = nul return $node; } + if ($fileId === null && $path === null) { + throw new NotFoundException(); + } + if ($path !== null) { $node = $node->get($path); } else { diff --git a/lib/Service/InitialStateService.php b/lib/Service/InitialStateService.php index a9b9b7408a..8afdcac290 100644 --- a/lib/Service/InitialStateService.php +++ b/lib/Service/InitialStateService.php @@ -28,34 +28,21 @@ use OCA\Richdocuments\AppInfo\Application; use OCA\Richdocuments\Db\Wopi; use OCP\AppFramework\Services\IInitialState; +use OCP\Defaults; use OCP\IConfig; +use OCP\IURLGenerator; class InitialStateService { - /** @var IInitialState */ - private $initialState; - - /** @var CapabilitiesService */ - private $capabilitiesService; - - /** @var IConfig */ - private $config; - - /** @var string|null */ - private $userId; - - /** @var bool */ - private $hasProvidedCapabilities = false; + private bool $hasProvidedCapabilities = false; public function __construct( - IInitialState $initialState, - CapabilitiesService $capabilitiesService, - IConfig $config, - $userId + private IInitialState $initialState, + private CapabilitiesService $capabilitiesService, + private IURLGenerator $urlGenerator, + private Defaults $themingDefaults, + private IConfig $config, + private ?string $userId, ) { - $this->initialState = $initialState; - $this->capabilitiesService = $capabilitiesService; - $this->config = $config; - $this->userId = $userId; } public function provideCapabilities(): void { @@ -66,6 +53,7 @@ public function provideCapabilities(): void { $this->initialState->provideInitialState('productName', $this->capabilitiesService->getProductName()); $this->initialState->provideInitialState('hasDrawSupport', $this->capabilitiesService->hasDrawSupport()); $this->initialState->provideInitialState('hasNextcloudBranding', $this->capabilitiesService->hasNextcloudBranding()); + $this->initialState->provideInitialState('instanceid', $this->config->getSystemValue('instanceid')); $this->provideOptions(); @@ -112,7 +100,7 @@ private function provideOptions(): void { $logoSet = $this->config->getAppValue('theming', 'logoMime', '') !== ''; } $this->initialState->provideInitialState('theming-customLogo', ($logoSet ? - \OC::$server->getURLGenerator()->getAbsoluteURL(\OC::$server->getThemingDefaults()->getLogo()) + $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo()) : false)); } }