🚧Changing file identifier with editing_session_id
This commit is contained in:
committed by
Eric Doughty-Papassideris
parent
688217dfdb
commit
ca3ebcc83d
@@ -74,17 +74,27 @@ class IndexController {
|
||||
throw new Error('You do not have access to this file');
|
||||
}
|
||||
|
||||
let editingSessionId = null;
|
||||
if (!preview) {
|
||||
editingSessionId = driveService.beginEditing(drive_file_id);
|
||||
//TODO catch error and display to the user when we can't stopped editing
|
||||
|
||||
//TODO Log error with format to be able to set up grafana alert fir such king of errors
|
||||
}
|
||||
|
||||
const officeToken = jwt.sign(
|
||||
{
|
||||
user_id: user.id, //To verify that link is opened by the same user
|
||||
company_id,
|
||||
drive_file_id,
|
||||
editing_session_id: editingSessionId,
|
||||
file_id: file.id,
|
||||
file_name: file.filename || file?.metadata?.name || '',
|
||||
preview: !!preview,
|
||||
} as OfficeToken,
|
||||
CREDENTIALS_SECRET,
|
||||
{
|
||||
//one month, never expiring token
|
||||
expiresIn: 60 * 60 * 24 * 30,
|
||||
},
|
||||
);
|
||||
@@ -93,6 +103,7 @@ class IndexController {
|
||||
Utils.joinURL([SERVER_ORIGIN ?? '', SERVER_PREFIX, 'editor'], {
|
||||
token,
|
||||
file_id,
|
||||
editing_session_id: editingSessionId,
|
||||
company_id,
|
||||
preview,
|
||||
office_token: officeToken,
|
||||
|
||||
@@ -74,7 +74,7 @@ class OnlyOfficeController {
|
||||
try {
|
||||
const { url, key } = req.body;
|
||||
const { token } = req.query;
|
||||
logger.info('Save request', { key, url, token });
|
||||
logger.info('OO callback', req.body);
|
||||
|
||||
const officeTokenPayload = jwt.verify(token, CREDENTIALS_SECRET) as OfficeToken;
|
||||
const { preview, company_id, file_id, /* user_id, */ drive_file_id, in_page_token } = officeTokenPayload;
|
||||
@@ -85,6 +85,9 @@ class OnlyOfficeController {
|
||||
|
||||
switch (req.body.status) {
|
||||
case OnlyOffice.Callback.Status.BEING_EDITED:
|
||||
// TODO this call back we recieve almost all the time, and here we save
|
||||
// the user identifiers who start file editing and even control the amount of onlin users
|
||||
// to have license constraint warning before OnlyOffice error about this
|
||||
case OnlyOffice.Callback.Status.BEING_EDITED_BUT_IS_SAVED:
|
||||
// No-op
|
||||
break;
|
||||
|
||||
@@ -2,7 +2,8 @@ import { DriveFileType, IDriveService } from '@/interfaces/drive.interface';
|
||||
import apiService from './api.service';
|
||||
import logger from '../lib/logger';
|
||||
|
||||
/** Client for Twake Drive's APIs dealing with `DriveItem`s, using {@see apiService}
|
||||
/**
|
||||
* Client for Twake Drive's APIs dealing with `DriveItem`s, using {@see apiService}
|
||||
* to handle authorization
|
||||
*/
|
||||
class DriveService implements IDriveService {
|
||||
@@ -47,6 +48,15 @@ class DriveService implements IDriveService {
|
||||
return Promise.reject();
|
||||
}
|
||||
};
|
||||
|
||||
public beginEditing(drive_file_id: string): string {
|
||||
return "";
|
||||
}
|
||||
|
||||
public endEditing(editing_session_id: string) {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default new DriveService();
|
||||
|
||||
Reference in New Issue
Block a user