diff --git a/DocService/sources/DocsCoServer.js b/DocService/sources/DocsCoServer.js index 6667161d..2b489a89 100644 --- a/DocService/sources/DocsCoServer.js +++ b/DocService/sources/DocsCoServer.js @@ -1086,6 +1086,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); @@ -2358,7 +2375,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; diff --git a/DocService/sources/wopiClient.js b/DocService/sources/wopiClient.js index c874aea5..a3457c6c 100644 --- a/DocService/sources/wopiClient.js +++ b/DocService/sources/wopiClient.js @@ -812,6 +812,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; @@ -1072,6 +1092,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;