|
5 | 5 | */ |
6 | 6 | namespace OCA\Richdocuments\Controller; |
7 | 7 |
|
| 8 | +use OCA\Files_Sharing\SharedMount; |
8 | 9 | use OCA\Files_Versions\Versions\IVersionManager; |
9 | 10 | use OCA\Richdocuments\AppConfig; |
10 | 11 | use OCA\Richdocuments\AppInfo\Application; |
@@ -219,7 +220,7 @@ public function checkFileInfo(string $fileId, string $access_token): JSONRespons |
219 | 220 | $response['TemplateSource'] = $this->getWopiUrlForTemplate($wopi); |
220 | 221 | } |
221 | 222 |
|
222 | | - $share = $this->getShareForWopiToken($wopi); |
| 223 | + $share = $this->getShareForWopiToken($wopi, $file); |
223 | 224 | if ($this->permissionManager->shouldWatermark($file, $wopi->getEditorUid(), $share)) { |
224 | 225 | $email = $user !== null && !$isPublic ? $user->getEMailAddress() : ''; |
225 | 226 | $currentDateTime = new \DateTime( |
@@ -925,9 +926,20 @@ private function getFileForWopiToken(Wopi $wopi) { |
925 | 926 | return array_shift($files); |
926 | 927 | } |
927 | 928 |
|
928 | | - private function getShareForWopiToken(Wopi $wopi): ?IShare { |
| 929 | + private function getShareForWopiToken(Wopi $wopi, File $file): ?IShare { |
929 | 930 | try { |
930 | | - return $wopi->getShare() ? $this->shareManager->getShareByToken($wopi->getShare()) : null; |
| 931 | + $shareToken = $wopi->getShare(); |
| 932 | + if ($shareToken) { |
| 933 | + return $this->shareManager->getShareByToken($shareToken); |
| 934 | + } |
| 935 | + |
| 936 | + // on internal shares the token is not stored, but we can use the |
| 937 | + // super share. It is not a specific share, but a cumulative one and# |
| 938 | + //carries necessary information |
| 939 | + $mount = $file->getMountPoint(); |
| 940 | + if ($mount instanceof SharedMount) { |
| 941 | + return $mount->getShare(); |
| 942 | + } |
931 | 943 | } catch (ShareNotFound) { |
932 | 944 | } |
933 | 945 |
|
|
0 commit comments