🐛Fixed document identifier for OnlyOffice in view mode

This commit is contained in:
Anton SHEPILOV
2024-08-25 22:26:28 +02:00
committed by Eric Doughty-Papassideris
parent 0914db9789
commit a692eabf3b
3 changed files with 5 additions and 15 deletions
@@ -144,6 +144,7 @@ class IndexController {
res.render('index', {
...initResponse,
docId: preview ? file_id : editing_session_key,
server: Utils.joinURL([SERVER_ORIGIN, SERVER_PREFIX]),
token: inPageToken,
});
@@ -28,26 +28,15 @@ class OnlyOfficeController {
const { token } = req.query;
const officeTokenPayload = jwt.verify(token, CREDENTIALS_SECRET) as OfficeToken;
const { company_id, drive_file_id, file_id, in_page_token, editing_session_key } = officeTokenPayload;
let fileId = file_id;
const { company_id, file_id, in_page_token } = officeTokenPayload;
// check token is an in_page_token
if (!in_page_token) throw new Error('Invalid token, must be a in_page_token');
if (drive_file_id) {
//Get the drive file
const driveFile = await driveService.getByEditingSessionKey({
company_id,
editing_session_key,
});
if (driveFile) {
fileId = driveFile?.item?.last_version_cache?.file_metadata?.external_id;
}
}
if (!file_id) throw new Error(`File id is missing in the last version cache for ${JSON.stringify(file_id)}`);
const file = await fileService.download({
company_id,
file_id: fileId,
file_id: file_id,
});
file.pipe(res);
@@ -26,7 +26,7 @@
title: "<%= it.filename %>",
url: `${window.baseURL}read?file_id=<%= it.file_id %>&company_id=<%= it.company_id %>&token=<%= it.token %>`,
fileType: "<%= it.file_type %>",
key: "<%= it.file_version_id %>",
key: "<%= it.docId %>",
token: "<%= it.file_id %>",
permissions: {
download: true,