Skip to content

Commit

Permalink
feat(wopi): pass WOPI settings if iframe capability is allowed
Browse files Browse the repository at this point in the history
Signed-off-by: codewithvk <vivek.javiya@collabora.com>
  • Loading branch information
codewithvk authored and elzody committed Feb 26, 2025
1 parent c7fd8b1 commit 852611b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/Controller/WopiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -90,6 +91,7 @@ public function __construct(
private IEventDispatcher $eventDispatcher,
private TaskProcessingManager $taskProcessingManager,
private SettingsService $settingsService,
private CapabilitiesService $capabilitiesService,
) {
parent::__construct($appName, $request);
}
Expand All @@ -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)) {
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit 852611b

Please sign in to comment.