diff --git a/cypress/e2e/share-federated.spec.js b/cypress/e2e/share-federated.spec.js index 7d00b44644..52f7c71587 100644 --- a/cypress/e2e/share-federated.spec.js +++ b/cypress/e2e/share-federated.spec.js @@ -16,6 +16,7 @@ describe('Federated sharing of office documents', function() { cy.createUser(shareOwner) cy.uploadFile(shareOwner, 'document.odt', 'application/vnd.oasis.opendocument.text', '/document.odt') + cy.uploadFile(shareOwner, 'document.odt', 'application/vnd.oasis.opendocument.text', '/document-reshare.odt') }) it('Open a remotely shared file', function() { @@ -37,4 +38,23 @@ describe('Federated sharing of office documents', function() { cy.get('#viewer', { timeout: 5000 }).should('not.exist') }) }) + + it('Open a remotely shared file as a link', function() { + cy.login(shareOwner) + cy.shareFileToRemoteUser(shareOwner, '/document-reshare.odt', shareRecipient) + + cy.login(shareRecipient) + cy.visit('/apps/files') + + cy.shareLink(shareRecipient, '/document-reshare.odt', { permissions: 1 }).then((token) => { + cy.logout() + cy.visit(`/s/${token}`, { + onBeforeLoad(win) { + cy.spy(win, 'postMessage').as('postMessage') + }, + }) + cy.waitForViewer() + cy.waitForCollabora(true, true) + }) + }) }) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 25f6248141..bf349140eb 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -133,6 +133,7 @@ Cypress.Commands.add('shareFileToRemoteUser', (user, path, targetUser, shareData body: { path, shareType: 6, + permission: 31, shareWith: federatedId, ...shareData, }, diff --git a/lib/Controller/DocumentController.php b/lib/Controller/DocumentController.php index 823381b924..72029d9cca 100644 --- a/lib/Controller/DocumentController.php +++ b/lib/Controller/DocumentController.php @@ -393,7 +393,7 @@ public function token(int $fileId, ?string $shareToken = null, ?string $path = n $share = $shareToken ? $this->shareManager->getShareByToken($shareToken) : null; $file = $shareToken ? $this->getFileForShare($share, $fileId, $path) : $this->getFileForUser($fileId, $path); - $federatedUrl = $this->federationService->getRemoteRedirectURL($file); + $federatedUrl = $this->federationService->getRemoteRedirectURL($file, null, $share); if ($federatedUrl) { return new DataResponse([ 'federatedUrl' => $federatedUrl,