Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[se] save back document opened from TemplateSource; For bug 69573 #489

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions DocService/sources/DocsCoServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ async function applyForceSaveCache(ctx, docId, forceSave, type, opt_userConnecti
}
async function startForceSave(ctx, docId, type, opt_userdata, opt_formdata, opt_userId, opt_userConnectionId,
opt_userConnectionDocId, opt_userIndex, opt_responseKey, opt_baseUrl,
opt_queue, opt_pubsub, opt_conn, opt_initShardKey, opt_jsonParams) {
opt_queue, opt_pubsub, opt_conn, opt_initShardKey, opt_jsonParams, opt_changeInfo) {
const tenForceSaveUsingButtonWithoutChanges = ctx.getCfg('services.CoAuthoring.server.forceSaveUsingButtonWithoutChanges', cfgForceSaveUsingButtonWithoutChanges);
ctx.logger.debug('startForceSave start');
let res = {code: commonDefines.c_oAscServerCommandErrors.NoError, time: null, inProgress: false};
Expand All @@ -940,15 +940,20 @@ async function startForceSave(ctx, docId, type, opt_userdata, opt_formdata, opt_
});
if (!hasEncrypted) {
let forceSave = await editorData.getForceSave(ctx, docId);
let startWithoutChanges = !forceSave && opt_conn && (commonDefines.c_oAscForceSaveTypes.Form === type ||
let forceSaveWithConnection = opt_conn && (commonDefines.c_oAscForceSaveTypes.Form === type ||
(commonDefines.c_oAscForceSaveTypes.Button === type && tenForceSaveUsingButtonWithoutChanges));
let startWithoutChanges = !forceSave && (forceSaveWithConnection || opt_changeInfo);
if (startWithoutChanges) {
//stub to send forms without changes
let newChangesLastDate = new Date();
newChangesLastDate.setMilliseconds(0);//remove milliseconds avoid issues with MySQL datetime rounding
let newChangesLastTime = newChangesLastDate.getTime();
let baseUrl = utils.getBaseUrlByConnection(ctx, opt_conn);
let changeInfo = getExternalChangeInfo(opt_conn.user, newChangesLastTime, opt_conn.lang);
let baseUrl = opt_baseUrl || "";
let changeInfo = opt_changeInfo;
if (opt_conn) {
baseUrl = utils.getBaseUrlByConnection(ctx, opt_conn);
changeInfo = getExternalChangeInfo(opt_conn.user, newChangesLastTime, opt_conn.lang);
}
await editorData.setForceSave(ctx, docId, newChangesLastTime, 0, baseUrl, changeInfo, null);
forceSave = await editorData.getForceSave(ctx, docId);
}
Expand Down Expand Up @@ -2815,6 +2820,12 @@ exports.install = function(server, callbackFunction) {
let openedAt = openedAtStr ? sqlBase.DocumentAdditional.prototype.getOpenedAt(openedAtStr) : canvasService.getOpenedAt(resultRow);
const endAuthRes = yield* endAuth(ctx, conn, false, documentCallback, openedAt);
if (endAuthRes && cmd) {
//todo to allow forcesave TemplateSource after convertion(move to better place)
if (wopiParamsFull?.commonInfo?.fileInfo?.TemplateSource) {
let newChangesLastDate = new Date();
newChangesLastDate.setMilliseconds(0);//remove milliseconds avoid issues with MySQL datetime rounding
cmd.setExternalChangeInfo(getExternalChangeInfo(conn.user, newChangesLastDate.getTime(), conn.lang));
}
yield canvasService.openDocument(ctx, conn, cmd, upsertRes, bIsRestore);
}
}
Expand Down
22 changes: 21 additions & 1 deletion DocService/sources/canvasservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ async function getOutputData(ctx, cmd, outputData, key, optConn, optAdditionalOu
password = sqlBase.DocumentPassword.prototype.getCurPassword(ctx, row.password);
creationDate = row.created_at && row.created_at.getTime();
openedAt = getOpenedAt(row);
if (optAdditionalOutput) {
optAdditionalOutput.row = row;
}
}
switch (status) {
case commonDefines.FileStatus.SaveVersion:
Expand Down Expand Up @@ -1826,9 +1829,26 @@ exports.receiveTask = function(data, ack) {
if (updateRes.affectedRows > 0) {
var outputData = new OutputData(cmd.getCommand());
var command = cmd.getCommand();
var additionalOutput = {needUrlKey: null, needUrlMethod: null, needUrlType: null, needUrlIsCorrectPassword: undefined, creationDate: undefined, openedAt: undefined};
var additionalOutput = {needUrlKey: null, needUrlMethod: null, needUrlType: null,
needUrlIsCorrectPassword: undefined, creationDate: undefined, openedAt: undefined, row: undefined};
if ('open' === command || 'reopen' === command) {
yield getOutputData(ctx, cmd, outputData, cmd.getDocId(), null, additionalOutput);
//wopi from TemplateSource
if (additionalOutput.row) {
let row = additionalOutput.row;
let userAuthStr = sqlBase.UserCallback.prototype.getCallbackByUserIndex(ctx, row.callback);
let wopiParams = wopiClient.parseWopiCallback(ctx, userAuthStr, row.callback);
if (wopiParams?.commonInfo?.fileInfo?.TemplateSource) {
ctx.logger.debug('receiveTask: save document opened from TemplateSource');
//todo
//no need to wait to open file faster
void docsCoServer.startForceSave(ctx, cmd.getDocId(), commonDefines.c_oAscForceSaveTypes.Timeout,
undefined, undefined, undefined, undefined,
undefined, undefined, undefined, row.baseurl,
undefined,undefined,undefined,undefined,
undefined,cmd.getExternalChangeInfo());
}
}
} else if ('save' === command || 'savefromorigin' === command) {
let status = yield getOutputData(ctx, cmd, outputData, cmd.getDocId() + cmd.getSaveKey(), null, additionalOutput);
if (commonDefines.FileStatus.Ok === status && (cmd.getSaveAsPath() || cmd.getIsSaveAs())) {
Expand Down
Loading