Skip to content

Commit

Permalink
fix: Properly get empty template for direct editing
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Knorr <[email protected]>
  • Loading branch information
juliusknorr committed Dec 13, 2024
1 parent 41f6a22 commit cb664d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion cypress/e2e/direct.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})
Expand Down
5 changes: 3 additions & 2 deletions lib/Controller/DirectViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down

0 comments on commit cb664d6

Please sign in to comment.