mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
[wopi] Add wopi_RefreshFile command; Stub for validateAuthToken
This commit is contained in:
@ -1092,6 +1092,23 @@ function* startRPC(ctx, conn, responseKey, data) {
|
||||
}
|
||||
sendDataRpc(ctx, conn, responseKey, renameRes);
|
||||
break;
|
||||
case 'wopi_RefreshFile': {
|
||||
let renameRes;
|
||||
let selectRes = yield taskResult.select(ctx, docId);
|
||||
let row = selectRes.length > 0 ? selectRes[0] : null;
|
||||
if (row) {
|
||||
if (row.callback) {
|
||||
let userIndex = utils.getIndexFromUserId(conn.user.id, conn.user.idOriginal);
|
||||
let uri = sqlBase.UserCallback.prototype.getCallbackByUserIndex(ctx, row.callback, userIndex);
|
||||
let wopiParams = wopiClient.parseWopiCallback(ctx, uri, row.callback);
|
||||
if (wopiParams) {
|
||||
renameRes = yield wopiClient.refreshFile(ctx, wopiParams, data.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
sendDataRpc(ctx, conn, responseKey, renameRes);
|
||||
break;
|
||||
}
|
||||
case 'pathurls':
|
||||
let outputData = new canvasService.OutputData(data.type);
|
||||
yield* canvasService.commandPathUrls(ctx, conn, data.data, outputData);
|
||||
@ -2372,7 +2389,8 @@ exports.install = function(server, callbackFunction) {
|
||||
} else if (data.mode && 'view' !== data.mode && !decoded?.editorConfig?.mode) {//allow to restrict rights to 'view'
|
||||
res = "editorConfig.mode";
|
||||
}
|
||||
return res;
|
||||
//todo
|
||||
return "";
|
||||
}
|
||||
function fillDataFromJwt(ctx, decoded, data) {
|
||||
let res = true;
|
||||
|
||||
@ -835,6 +835,26 @@ function renameFile(ctx, wopiParams, name) {
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
async function refreshFile(ctx, wopiParams) {
|
||||
let fileInfo = {};
|
||||
try {
|
||||
ctx.logger.info('wopi RefreshFile start');
|
||||
if (!wopiParams.userAuth) {
|
||||
return res;
|
||||
}
|
||||
let userAuth = wopiParams.userAuth;
|
||||
|
||||
fileInfo = await checkFileInfo(ctx, userAuth.wopiSrc, userAuth.access_token);
|
||||
//todo jwt token
|
||||
|
||||
} catch (err) {
|
||||
ctx.logger.error('wopi error RefreshFile:%s', err.stack);
|
||||
} finally {
|
||||
utils.fillResponseSimple(res, JSON.stringify(fileInfo), "application/json");
|
||||
ctx.logger.info('wopi RefreshFile end');
|
||||
}
|
||||
}
|
||||
function checkFileInfo(ctx, wopiSrc, access_token, opt_sc) {
|
||||
return co(function* () {
|
||||
let fileInfo = undefined;
|
||||
@ -1099,6 +1119,7 @@ exports.putFile = putFile;
|
||||
exports.parsePutFileResponse = parsePutFileResponse;
|
||||
exports.putRelativeFile = putRelativeFile;
|
||||
exports.renameFile = renameFile;
|
||||
exports.refreshFile = refreshFile;
|
||||
exports.lock = lock;
|
||||
exports.unlock = unlock;
|
||||
exports.fillStandardHeaders = fillStandardHeaders;
|
||||
|
||||
Reference in New Issue
Block a user