diff --git a/cypress/e2e/direct.spec.js b/cypress/e2e/direct.spec.js index b0120cc536..66bf0c6ba7 100644 --- a/cypress/e2e/direct.spec.js +++ b/cypress/e2e/direct.spec.js @@ -121,8 +121,13 @@ describe('Direct editing (legacy)', function() { createNewFileDirectEditingLink(randUser, 'mynewfile.odt', emptyTemplate.id) .then((token) => { cy.logout() - cy.visit(token) + cy.visit(token, { + onBeforeLoad(win) { + cy.spy(win, 'postMessage').as('postMessage') + }, + }) cy.waitForCollabora(false) + cy.waitForPostMessage('App_LoadingStatus', { Status: 'Document_Loaded' }) cy.screenshot('direct-new') }) }) diff --git a/lib/Controller/DirectViewController.php b/lib/Controller/DirectViewController.php index 5d648ee6f1..30b72c933d 100644 --- a/lib/Controller/DirectViewController.php +++ b/lib/Controller/DirectViewController.php @@ -94,16 +94,17 @@ public function show($token) { } $wopi = null; - $template = $direct->getTemplateId() ? $this->templateManager->getTemplateSource($direct->getTemplateId()) : null; + $template = $direct->getTemplateId() ? $this->templateManager->get($direct->getTemplateId()) : null; if ($template !== null) { $wopi = $this->tokenManager->generateWopiTokenForTemplate($template, $item->getId(), $direct->getUid(), false, true); } if ($wopi === null) { - $urlSrc = $this->tokenManager->getUrlSrc($item); $wopi = $this->tokenManager->generateWopiToken((string)$item->getId(), null, $direct->getUid(), true); } + + $urlSrc = $this->tokenManager->getUrlSrc($item); } catch (\Exception $e) { $this->logger->error('Failed to generate token for existing file on direct editing', ['exception' => $e]); return $this->renderErrorPage('Failed to open the requested file.');