handle the presentation leader parameter

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
This commit is contained in:
Pranam Lashkari 2025-11-10 15:59:46 +00:00
parent a38ab9701f
commit 13a1fb6659
8 changed files with 25 additions and 12 deletions

View file

@ -18,7 +18,7 @@ return [
['name' => 'document#heartbeat', 'url' => '/heartbeat', 'verb' => 'GET'],
['name' => 'document#editOnline', 'url' => 'editonline', 'verb' => 'GET'],
['name' => 'document#editOnlineFollowMeSlideShow', 'url' => 'editonline/followPresentation/{fileId}', 'verb' => 'GET'],
['name' => 'document#editOnlineFollowMeSlideShow', 'url' => 'editonline/followPresentation/{fileId}/{leaderId}', 'verb' => 'GET'],
['name' => 'document#editOnlineTarget', 'url' => 'editonline/{fileId}/{target}', 'verb' => 'GET'],
// external api access

View file

@ -386,7 +386,7 @@ class DocumentController extends Controller {
#[NoCSRFRequired]
#[NoAdminRequired]
#[UseSession]
public function editOnlineFollowMeSlideShow(int $fileId): RedirectResponse|TemplateResponse {
public function editOnlineFollowMeSlideShow(int $fileId, ?string $leaderId = null): RedirectResponse|TemplateResponse {
if (!$this->userId) {
return $this->renderErrorPage('File not found', Http::STATUS_NOT_FOUND);
}
@ -398,10 +398,11 @@ class DocumentController extends Controller {
'fileId' => $file->getId()
]);
$filePath = $file->getFileInfo()->getInternalPath();
$directoryPath = substr($filePath, 0, strrpos($filePath, '/') + 1);
$redirectUrl = $this->urlGenerator->getAbsoluteURL('/index.php/apps/files/' . $directoryPath . $file->getId());
$parameters = '?openfile=true&startFollowMePresentation=true';
$filePath = $file->getPath();
$pathPrefixLen = strlen('/' . $this->userId. '/files');
$directoryPath = substr($filePath, $pathPrefixLen , strrpos($filePath, '/') - $pathPrefixLen + 1);
$redirectUrl = $this->urlGenerator->getAbsoluteURL('/index.php/apps/files/files/' . $file->getId());
$parameters = '?openfile=true&startFollowMePresentation=true&presentationLeaderId=' . $leaderId . '&dir=' . $directoryPath;
$redirectUrl = $redirectUrl . $parameters;
return new RedirectResponse($redirectUrl);
} catch (NotFoundException|NotPermittedException|NoUserException) {

View file

@ -38,5 +38,9 @@ class BeforeTemplateRenderedListener implements IEventListener {
$startFollowMePresentation = $this->request->getParam('startFollowMePresentation') === 'true';
$this->initialStateService->provideFollowPresentation($startFollowMePresentation);
$presentationLeaderId = $this->request->getParam('presentationLeaderId');
if ($presentationLeaderId)
$this->initialStateService->providePresentationLeader($presentationLeaderId);
}
}

View file

@ -39,8 +39,8 @@ class OfficePresentationStarter extends ADiscoverableReferenceProvider {
$start = $this->urlGenerator->getAbsoluteURL('/apps/' . Application::APPNAME);
$startIndex = $this->urlGenerator->getAbsoluteURL('/index.php/apps/' . Application::APPNAME);
$noIndexMatch = preg_match('/^' . preg_quote($start, '/') . '\/editonline\/followPresentation\/([0-9]+)/', $referenceText) === 1;
$indexMatch = preg_match('/^' . preg_quote($startIndex, '/') . '\/editonline\/followPresentation\/([0-9]+)/', $referenceText) === 1;
$noIndexMatch = preg_match('/^' . preg_quote($start, '/') . '\/editonline\/followPresentation\/([0-9]+)\/(.*)$/', $referenceText) === 1;
$indexMatch = preg_match('/^' . preg_quote($startIndex, '/') . '\/editonline\/followPresentation\/([0-9]+)\/(.*)$/', $referenceText) === 1;
return $noIndexMatch || $indexMatch;
}
@ -52,9 +52,9 @@ class OfficePresentationStarter extends ADiscoverableReferenceProvider {
$start = $this->urlGenerator->getAbsoluteURL('/apps/' . Application::APPNAME);
$startIndex = $this->urlGenerator->getAbsoluteURL('/index.php/apps/' . Application::APPNAME);
$matched = preg_match('/^' . preg_quote($start, '/') . '\/editonline\/followPresentation\/([0-9]+)/', $referenceText, $matches) === 1;
$matched = preg_match('/^' . preg_quote($start, '/') . '\/editonline\/followPresentation\/([0-9]+)\/(.*)$/', $referenceText, $matches) === 1;
if (!$matched) {
$matched = preg_match('/^' . preg_quote($startIndex, '/') . '\/editonline\/followPresentation\/([0-9]+)/', $referenceText, $matches) === 1;
$matched = preg_match('/^' . preg_quote($startIndex, '/') . '\/editonline\/followPresentation\/([0-9]+)\/(.*)$/', $referenceText, $matches) === 1;
}
if (!$matched) {

View file

@ -68,6 +68,10 @@ class InitialStateService {
$this->initialState->provideInitialState('startFollowMePresentation', $startFollowMePresentation);
}
public function providePresentationLeader(string $presentationLeaderId): void {
$this->initialState->provideInitialState('presentationLeaderId', $presentationLeaderId);
}
public function provideAdminSettings(): void {
$this->initialState->provideInitialState('adminSettings', [
'templatesAvailable' => $this->capabilitiesService->hasTemplateSource(),

View file

@ -29,7 +29,7 @@ const getWopiSrc = (fileId) => {
return wopiurl
}
const getWopiUrl = ({ fileId, readOnly, closeButton, revisionHistory, target = undefined, startPresentation = false, startFollowMePresentation = false }) => {
const getWopiUrl = ({ fileId, readOnly, closeButton, revisionHistory, target = undefined, startPresentation = false, startFollowMePresentation = false, presentationLeaderId = '' }) => {
// Only set the revision history parameter if the versions app is enabled
revisionHistory = revisionHistory && window?.oc_appswebroots?.files_versions
@ -46,6 +46,7 @@ const getWopiUrl = ({ fileId, readOnly, closeButton, revisionHistory, target = u
+ (target ? '&target=' + encodeURIComponent(target) : '')
+ (startPresentation ? '&startPresentation=1' : '')
+ (startFollowMePresentation ? '&startFollowMePresentation=1' : '')
+ (presentationLeaderId ? '&presentationLeaderId=' + presentationLeaderId : '')
}
const getDocumentUrlFromTemplate = (templateId, fileName, fileDir, fillWithTemplate) => {

View file

@ -23,6 +23,7 @@ import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
import NcListItem from '@nextcloud/vue/dist/Components/NcListItem.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import TableOfContentsIcon from 'vue-material-design-icons/TableOfContents.vue'
import { getCurrentUser } from '@nextcloud/auth'
export default {
name: 'FollowMePresentationPicker',
@ -99,7 +100,7 @@ export default {
},
submit() {
const fileLink = window.location.protocol + '//' + window.location.host
+ generateUrl('/apps/richdocuments/editonline/followPresentation/{fileId}', { fileId: this.fileId })
+ generateUrl('/apps/richdocuments/editonline/followPresentation/{fileId}/{leaderId}', { fileId: this.fileId, leaderId: getCurrentUser().uid })
this.$emit('submit', fileLink)
},
async fetchReferences() {

View file

@ -326,6 +326,7 @@ export default {
Config.update('wopi_callback_url', loadState('richdocuments', 'wopi_callback_url', ''))
Config.update('startPresentation', loadState('richdocuments', 'startPresentation', false))
Config.update('startFollowMePresentation', loadState('richdocuments', 'startFollowMePresentation', false))
Config.update('presentationLeaderId', loadState('richdocuments', 'presentationLeaderId', false))
const forceReadOnly = this.isEmbedded && !this.hasWidgetEditingEnabled
@ -338,6 +339,7 @@ export default {
startPresentation: Config.get('startPresentation'),
target: data.target,
startFollowMePresentation: Config.get('startFollowMePresentation'),
presentationLeaderId: Config.get('presentationLeaderId'),
})
this.$set(this.formData, 'action', action)
this.$set(this.formData, 'accessToken', data.token)