🐛Fixed document identifier for OnlyOffice in view mode
This commit is contained in:
committed by
Eric Doughty-Papassideris
parent
0914db9789
commit
a692eabf3b
@@ -144,6 +144,7 @@ class IndexController {
|
|||||||
|
|
||||||
res.render('index', {
|
res.render('index', {
|
||||||
...initResponse,
|
...initResponse,
|
||||||
|
docId: preview ? file_id : editing_session_key,
|
||||||
server: Utils.joinURL([SERVER_ORIGIN, SERVER_PREFIX]),
|
server: Utils.joinURL([SERVER_ORIGIN, SERVER_PREFIX]),
|
||||||
token: inPageToken,
|
token: inPageToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,26 +28,15 @@ class OnlyOfficeController {
|
|||||||
const { token } = req.query;
|
const { token } = req.query;
|
||||||
|
|
||||||
const officeTokenPayload = jwt.verify(token, CREDENTIALS_SECRET) as OfficeToken;
|
const officeTokenPayload = jwt.verify(token, CREDENTIALS_SECRET) as OfficeToken;
|
||||||
const { company_id, drive_file_id, file_id, in_page_token, editing_session_key } = officeTokenPayload;
|
const { company_id, file_id, in_page_token } = officeTokenPayload;
|
||||||
let fileId = file_id;
|
|
||||||
|
|
||||||
// check token is an in_page_token
|
// check token is an in_page_token
|
||||||
if (!in_page_token) throw new Error('Invalid token, must be a in_page_token');
|
if (!in_page_token) throw new Error('Invalid token, must be a in_page_token');
|
||||||
|
|
||||||
if (drive_file_id) {
|
if (!file_id) throw new Error(`File id is missing in the last version cache for ${JSON.stringify(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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const file = await fileService.download({
|
const file = await fileService.download({
|
||||||
company_id,
|
company_id,
|
||||||
file_id: fileId,
|
file_id: file_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
file.pipe(res);
|
file.pipe(res);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
title: "<%= it.filename %>",
|
title: "<%= it.filename %>",
|
||||||
url: `${window.baseURL}read?file_id=<%= it.file_id %>&company_id=<%= it.company_id %>&token=<%= it.token %>`,
|
url: `${window.baseURL}read?file_id=<%= it.file_id %>&company_id=<%= it.company_id %>&token=<%= it.token %>`,
|
||||||
fileType: "<%= it.file_type %>",
|
fileType: "<%= it.file_type %>",
|
||||||
key: "<%= it.file_version_id %>",
|
key: "<%= it.docId %>",
|
||||||
token: "<%= it.file_id %>",
|
token: "<%= it.file_id %>",
|
||||||
permissions: {
|
permissions: {
|
||||||
download: true,
|
download: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user