@@ -129,9 +129,6 @@ public function checkFileInfo(string $fileId, string $access_token): JSONRespons
129
129
$ isSmartPickerEnabled = (bool )$ wopi ->getCanwrite () && !$ isPublic && !$ wopi ->getDirect ();
130
130
$ isTaskProcessingEnabled = $ isSmartPickerEnabled && $ this ->taskProcessingManager ->isTaskProcessingEnabled ();
131
131
132
- $ userSettings = $ this ->generateSettings ($ wopi , 'userconfig ' );
133
- $ sharedSettings = $ this ->generateSettings ($ wopi , 'systemconfig ' );
134
-
135
132
// If the file is locked manually by a user we want to open it read only for all others
136
133
$ canWriteThroughLock = true ;
137
134
try {
@@ -140,11 +137,16 @@ public function checkFileInfo(string $fileId, string $access_token): JSONRespons
140
137
} catch (NoLockProviderException |PreConditionNotMetException ) {
141
138
}
142
139
140
+ $ userId = !$ isPublic ? $ wopi ->getEditorUid () : $ guestUserId ;
141
+
142
+ $ userSettings = $ this ->generateSettings ($ userId , 'userconfig ' );
143
+ $ sharedSettings = $ this ->generateSettings ($ userId , 'systemconfig ' );
144
+
143
145
$ response = [
144
146
'BaseFileName ' => $ file ->getName (),
145
147
'Size ' => $ file ->getSize (),
146
148
'Version ' => $ version ,
147
- 'UserId ' => ! $ isPublic ? $ wopi -> getEditorUid () : $ guestUserId ,
149
+ 'UserId ' => $ userId ,
148
150
'OwnerId ' => $ wopi ->getOwnerUid (),
149
151
'UserFriendlyName ' => $ userDisplayName ,
150
152
'UserExtraInfo ' => [],
@@ -976,15 +978,13 @@ private function getWopiUrlForTemplate(Wopi $wopi): string {
976
978
$ nextcloudUrl = $ this ->appConfig ->getNextcloudUrl () ?: trim ($ this ->urlGenerator ->getAbsoluteURL ('' ), '/ ' );
977
979
return $ nextcloudUrl . '/index.php/apps/richdocuments/wopi/template/ ' . $ wopi ->getTemplateId () . '?access_token= ' . $ wopi ->getToken ();
978
980
}
979
- private function generateSettingToken (Wopi $ wopi ): string {
980
- $ userId = $ wopi ->getEditorUid ();
981
- $ res = $ this ->settingsService ->generateIframeToken ('user ' , $ userId );
982
- return $ res ['token ' ];
981
+ private function generateSettingToken (string $ userId ): string {
982
+ return $ this ->settingsService ->generateIframeToken ('user ' , $ userId )['token ' ];
983
983
}
984
984
// todo extract nextcloud url from everything
985
- private function generateSettings (Wopi $ wopi , string $ type ): array {
985
+ private function generateSettings (string $ userId , string $ type ): array {
986
986
$ nextcloudUrl = $ this ->appConfig ->getNextcloudUrl () ?: trim ($ this ->urlGenerator ->getAbsoluteURL ('' ), '/ ' );
987
- $ uri = $ nextcloudUrl . '/index.php/apps/richdocuments/wopi/settings ' . '?type= ' . $ type . '&access_token= ' . $ this ->generateSettingToken ($ wopi ) . '&fileId= ' . '-1 ' ;
987
+ $ uri = $ nextcloudUrl . '/index.php/apps/richdocuments/wopi/settings ' . '?type= ' . $ type . '&access_token= ' . $ this ->generateSettingToken ($ userId ) . '&fileId= ' . '-1 ' ;
988
988
return [
989
989
'uri ' => $ uri ,
990
990
'stamp ' => time ()
0 commit comments