Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/Service/InitialStateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function provideCapabilities(): void {
$this->initialState->provideInitialState('hasDrawSupport', $this->capabilitiesService->hasDrawSupport());
$this->initialState->provideInitialState('hasNextcloudBranding', $this->capabilitiesService->hasNextcloudBranding());
$this->initialState->provideInitialState('instanceId', $this->config->getSystemValue('instanceid'));
$this->initialState->provideInitialState('wopi_callback_url', $this->config->getAppValue(Application::APPNAME, 'wopi_callback_url', ''));

$this->provideOptions();

Expand Down Expand Up @@ -81,6 +82,7 @@ public function prepareParams(array $params): array {
'directGuest' => false,
'path' => '',
'urlsrc' => '',
'wopi_callback_url' => $this->config->getAppValue(Application::APPNAME, 'wopi_callback_url', ''),
'fileId' => '',
'title' => '',
'permissions' => '',
Expand Down
18 changes: 15 additions & 3 deletions src/helpers/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import { getRootUrl, generateUrl } from '@nextcloud/router'
import { languageToBCP47 } from './index.js'
import Config from './../services/config.tsx'
import { loadState } from '@nextcloud/initial-state'

const getSearchParam = (name) => {
const results = new RegExp('[?&]' + name + '=([^&#]*)').exec(window.location.href)
Expand All @@ -32,13 +33,24 @@ const getSearchParam = (name) => {
return decodeURI(results[1]) || ''
}

const getCallbackBaseUrl = () => {
const callbackUrl = Config.get('wopi_callback_url') || loadState('richdocuments', 'wopi_callback_url', '')
return callbackUrl || window.location.protocol + '//' + window.location.host + getRootUrl()
}

const getWopiSrc = (fileId) => {
// WOPISrc - URL that Collabora will use to access Nextcloud
// index.php is forced here to avoid different wopi srcs for the same document
const wopiurl = getCallbackBaseUrl() + '/index.php/apps/richdocuments/wopi/files/' + fileId
console.debug('[getWopiUrl] ' + wopiurl)
return wopiurl
}

const getWopiUrl = ({ fileId, title, readOnly, closeButton, revisionHistory, target = undefined }) => {
// Only set the revision history parameter if the versions app is enabled
revisionHistory = revisionHistory && window?.oc_appswebroots?.files_versions

// WOPISrc - URL that loolwsd will access (ie. pointing to ownCloud)
// index.php is forced here to avoid different wopi srcs for the same document
const wopiurl = window.location.protocol + '//' + window.location.host + getRootUrl() + '/index.php/apps/richdocuments/wopi/files/' + fileId
const wopiurl = getWopiSrc(fileId)
console.debug('[getWopiUrl] ' + wopiurl)
const wopisrc = encodeURIComponent(wopiurl)

Expand Down