From e7e3f09f34053771bceab38b2131a5c142caeaa6 Mon Sep 17 00:00:00 2001 From: codewithvk Date: Wed, 29 Jan 2025 16:02:07 +0530 Subject: [PATCH] fix: code cleanups Signed-off-by: codewithvk --- lib/Controller/DocumentController.php | 1 - lib/Controller/SettingsController.php | 1 - lib/Controller/WopiController.php | 4 ++-- lib/TokenManager.php | 4 +--- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/Controller/DocumentController.php b/lib/Controller/DocumentController.php index 3e5c26ac66..55d0c91fae 100644 --- a/lib/Controller/DocumentController.php +++ b/lib/Controller/DocumentController.php @@ -385,7 +385,6 @@ public function editOnlineTarget(int $fileId, ?string $target = null): RedirectR #[PublicPage] public function token(int $fileId, ?string $shareToken = null, ?string $path = null, ?string $guestName = null): DataResponse { try { - // Normal file handling (unchanged) $share = $shareToken ? $this->shareManager->getShareByToken($shareToken) : null; $file = $shareToken ? $this->getFileForShare($share, $fileId, $path) : $this->getFileForUser($fileId, $path); diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index b21a9beeca..0db8d555dc 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -101,7 +101,6 @@ public function demoServers(): DataResponse { public function getSettings(): JSONResponse { return new JSONResponse($this->getSettingsData()); } - // TODO : Provide Auth tokens here :) private function getSettingsData(): array { return [ 'wopi_url' => $this->appConfig->getCollaboraUrlInternal(), diff --git a/lib/Controller/WopiController.php b/lib/Controller/WopiController.php index 979ed8c71e..1a2aa1edb5 100644 --- a/lib/Controller/WopiController.php +++ b/lib/Controller/WopiController.php @@ -103,9 +103,9 @@ public function __construct( #[FrontpageRoute(verb: 'GET', url: 'wopi/files/{fileId}')] public function checkFileInfo(string $fileId, string $access_token): JSONResponse { try { - $wopi = $this->wopiMapper->getWopiForToken($access_token); - [$fileId, , $version] = Helper::parseFileId($fileId); + + $wopi = $this->wopiMapper->getWopiForToken($access_token); $file = $this->getFileForWopiToken($wopi); if (!($file instanceof File)) { throw new NotFoundException('No valid file found for ' . $fileId); diff --git a/lib/TokenManager.php b/lib/TokenManager.php index d2f8ba5b45..c4a8636354 100644 --- a/lib/TokenManager.php +++ b/lib/TokenManager.php @@ -48,13 +48,11 @@ public function __construct( * @throws Exception */ public function generateWopiToken(string $fileId, ?string $shareToken = null, ?string $editoruid = null, bool $direct = false): Wopi { - + [$fileId, , $version] = Helper::parseFileId($fileId); $owneruid = null; $hideDownload = false; $rootFolder = $this->rootFolder; - [$fileId, , $version] = Helper::parseFileId($fileId); - // if the user is not logged-in do use the sharers storage if ($shareToken !== null) { /** @var File $file */