From 852611b8f59aeb2a53978a3969a4254c634e69aa Mon Sep 17 00:00:00 2001 From: codewithvk Date: Wed, 5 Feb 2025 23:21:05 +0530 Subject: [PATCH] feat(wopi): pass WOPI settings if iframe capability is allowed Signed-off-by: codewithvk --- lib/Controller/WopiController.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/Controller/WopiController.php b/lib/Controller/WopiController.php index 1a2aa1edb5..8520783051 100644 --- a/lib/Controller/WopiController.php +++ b/lib/Controller/WopiController.php @@ -16,6 +16,7 @@ use OCA\Richdocuments\Exceptions\UnknownTokenException; use OCA\Richdocuments\Helper; use OCA\Richdocuments\PermissionManager; +use OCA\Richdocuments\Service\CapabilitiesService; use OCA\Richdocuments\Service\FederationService; use OCA\Richdocuments\Service\SettingsService; use OCA\Richdocuments\Service\UserScopeService; @@ -90,6 +91,7 @@ public function __construct( private IEventDispatcher $eventDispatcher, private TaskProcessingManager $taskProcessingManager, private SettingsService $settingsService, + private CapabilitiesService $capabilitiesService, ) { parent::__construct($appName, $request); } @@ -104,7 +106,7 @@ public function __construct( public function checkFileInfo(string $fileId, string $access_token): JSONResponse { try { [$fileId, , $version] = Helper::parseFileId($fileId); - + $wopi = $this->wopiMapper->getWopiForToken($access_token); $file = $this->getFileForWopiToken($wopi); if (!($file instanceof File)) { @@ -139,10 +141,6 @@ public function checkFileInfo(string $fileId, string $access_token): JSONRespons $userId = !$isPublic ? $wopi->getEditorUid() : $guestUserId; - if (!$isPublic) { - $userSettings = $this->generateSettings($userId, 'userconfig'); - } - $sharedSettings = $this->generateSettings($userId, 'systemconfig'); $response = [ 'BaseFileName' => $file->getName(), @@ -176,11 +174,14 @@ public function checkFileInfo(string $fileId, string $access_token): JSONRespons 'EnableRemoteAIContent' => $isTaskProcessingEnabled, 'HasContentRange' => true, 'ServerPrivateInfo' => [], - 'SharedSettings' => $sharedSettings, ]; - if (!$isPublic) { - $response['UserSettings'] = $userSettings; + if ($this->capabilitiesService->hasSettingIframeSupport()) { + + if (!$isPublic) { + $response['UserSettings'] = $this->generateSettings($userId, 'userconfig'); + } + $response['SharedSettings'] = $this->generateSettings($userId, 'systemconfig'); } $enableZotero = $this->config->getAppValue(Application::APPNAME, 'zoteroEnabled', 'yes') === 'yes';