Skip to content

Commit c49acd5

Browse files
committed
fix: set proper WOPI response and remove unnecessary WOPI callback from iframe
Signed-off-by: codewithvk <[email protected]>
1 parent 557305a commit c49acd5

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

lib/Controller/WopiController.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,7 @@ public function checkFileInfo(string $fileId, string $access_token): JSONRespons
105105
try {
106106
$wopi = $this->wopiMapper->getWopiForToken($access_token);
107107

108-
// TODO: condition for $wopi not found? -auth???
109-
110-
$userSettingsUri = $this->generateUserSettingsUri($wopi);
111-
112-
if ($fileId == '-1' && $wopi->getTokenType() == WOPI::TOKEN_TYPE_SETTING_AUTH) {
113-
$response = [
114-
'UserSettingsUri' => $userSettingsUri,
115-
];
116-
117-
return new JSONResponse($response);
118-
}
119-
120108
[$fileId, , $version] = Helper::parseFileId($fileId);
121-
122109
$file = $this->getFileForWopiToken($wopi);
123110
if (!($file instanceof File)) {
124111
throw new NotFoundException('No valid file found for ' . $fileId);
@@ -142,6 +129,9 @@ public function checkFileInfo(string $fileId, string $access_token): JSONRespons
142129
$isSmartPickerEnabled = (bool)$wopi->getCanwrite() && !$isPublic && !$wopi->getDirect();
143130
$isTaskProcessingEnabled = $isSmartPickerEnabled && $this->taskProcessingManager->isTaskProcessingEnabled();
144131

132+
$userSettings = $this->generateSettings($wopi, 'userconfig');
133+
$sharedSettings = $this->generateSettings($wopi, 'systemconfig');
134+
145135
// If the file is locked manually by a user we want to open it read only for all others
146136
$canWriteThroughLock = true;
147137
try {
@@ -182,7 +172,8 @@ public function checkFileInfo(string $fileId, string $access_token): JSONRespons
182172
'EnableRemoteAIContent' => $isTaskProcessingEnabled,
183173
'HasContentRange' => true,
184174
'ServerPrivateInfo' => [],
185-
'UserSettingsUri' => $userSettingsUri,
175+
'UserSettings' => $userSettings,
176+
// 'SharedSettings' => $sharedSettings,
186177
];
187178

188179
$enableZotero = $this->config->getAppValue(Application::APPNAME, 'zoteroEnabled', 'yes') === 'yes';
@@ -991,8 +982,12 @@ private function generateSettingToken(Wopi $wopi): string {
991982
return $res['token'];
992983
}
993984
// todo extract nextcloud url from everything
994-
private function generateUserSettingsUri(Wopi $wopi): string {
985+
private function generateSettings(Wopi $wopi, string $type): array {
995986
$nextcloudUrl = $this->appConfig->getNextcloudUrl() ?: trim($this->urlGenerator->getAbsoluteURL(''), '/');
996-
return $nextcloudUrl . '/index.php/apps/richdocuments/wopi/settings' . '?type=userconfig' . '&access_token=' . $this->generateSettingToken($wopi) . '&fileId=' . '-1';
987+
$uri = $nextcloudUrl . '/index.php/apps/richdocuments/wopi/settings' . '?type=' . $type . '&access_token=' . $this->generateSettingToken($wopi) . '&fileId=' . '-1';
988+
return [
989+
'uri' => $uri,
990+
'stamp' => time()
991+
];
997992
}
998993
}

src/helpers/url.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,8 @@ const getNextcloudUrl = () => {
9090
}
9191

9292
export const getCoolServerUrl = (collaboraBaseUrl) => {
93-
// todo fix wopi Url
94-
const wopiurl = getCallbackBaseUrl() + '/index.php/apps/richdocuments/wopi/files/-1'
95-
9693
return collaboraBaseUrl
97-
+ '/browser/dist/admin/adminIntegratorSettings.html?'
98-
+ 'WOPISrc=' + encodeURIComponent(wopiurl)
94+
+ '/browser/dist/admin/adminIntegratorSettings.html'
9995
}
10096

10197
export {

0 commit comments

Comments
 (0)