mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
[bug] Set isPrint flag while form submission
This commit is contained in:
@ -32,6 +32,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const config = require("config");
|
||||
const constants = require('./constants');
|
||||
|
||||
function InputCommand(data, copyExplicit) {
|
||||
@ -365,8 +366,12 @@ InputCommand.prototype = {
|
||||
getJsonParams: function() {
|
||||
return this['jsonparams'];
|
||||
},
|
||||
setJsonParams: function(data) {
|
||||
this['jsonparams'] = data;
|
||||
appendJsonParams: function (data) {
|
||||
if (this['jsonparams']) {
|
||||
config.util.extendDeep(this['jsonparams'], data);
|
||||
} else {
|
||||
this['jsonparams'] = data;
|
||||
}
|
||||
},
|
||||
getLCID: function() {
|
||||
return this['lcid'];
|
||||
|
||||
@ -916,7 +916,9 @@ async function applyForceSaveCache(ctx, docId, forceSave, type, opt_userConnecti
|
||||
}
|
||||
return res;
|
||||
}
|
||||
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) {
|
||||
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) {
|
||||
ctx.logger.debug('startForceSave start');
|
||||
let res = {code: commonDefines.c_oAscServerCommandErrors.NoError, time: null, inProgress: false};
|
||||
let startedForceSave;
|
||||
@ -974,7 +976,7 @@ async function startForceSave(ctx, docId, type, opt_userdata, opt_formdata, opt_
|
||||
//start new convert
|
||||
let status = await converterService.convertFromChanges(ctx, docId, baseUrl, forceSave, startedForceSave.changeInfo,
|
||||
opt_userdata, opt_formdata, opt_userConnectionId, opt_userConnectionDocId, opt_responseKey, priority, expiration,
|
||||
opt_queue, undefined, opt_initShardKey);
|
||||
opt_queue, undefined, opt_initShardKey, opt_jsonParams);
|
||||
if (constants.NO_ERROR === status.err) {
|
||||
res.time = forceSave.getTime();
|
||||
if (commonDefines.c_oAscForceSaveTypes.Timeout === type) {
|
||||
@ -1036,9 +1038,11 @@ function* startRPC(ctx, conn, responseKey, data) {
|
||||
case 'sendForm': {
|
||||
let forceSaveRes;
|
||||
if (conn.user) {
|
||||
//isPrint - to remove forms
|
||||
let jsonParams = {'documentLayout': {'isPrint': true}};
|
||||
forceSaveRes = yield startForceSave(ctx, docId, commonDefines.c_oAscForceSaveTypes.Form, undefined,
|
||||
data.formdata, conn.user.idOriginal, conn.user.id, undefined, conn.user.indexUser,
|
||||
responseKey, undefined, undefined, undefined, conn);
|
||||
responseKey, undefined, undefined, undefined, conn, undefined, jsonParams);
|
||||
}
|
||||
if (!forceSaveRes || commonDefines.c_oAscServerCommandErrors.NoError !== forceSaveRes.code || forceSaveRes.inProgress) {
|
||||
sendDataRpc(ctx, conn, responseKey, forceSaveRes);
|
||||
|
||||
@ -162,7 +162,7 @@ function getOpenedAt(row) {
|
||||
function getOpenedAtJSONParams(row) {
|
||||
let openedAt = getOpenedAt(row);
|
||||
if (openedAt) {
|
||||
return JSON.stringify({'documentLayout': {'openedAt': openedAt}});
|
||||
return {'documentLayout': {'openedAt': openedAt}};
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@ -635,7 +635,7 @@ let commandSfctByCmd = co.wrap(function*(ctx, cmd, opt_priority, opt_expiration,
|
||||
let userAuthStr = sqlBase.UserCallback.prototype.getCallbackByUserIndex(ctx, row.callback);
|
||||
cmd.setWopiParams(wopiClient.parseWopiCallback(ctx, userAuthStr, row.callback));
|
||||
cmd.setOutputFormat(changeFormatByOrigin(ctx, row, cmd.getOutputFormat()));
|
||||
cmd.setJsonParams(getOpenedAtJSONParams(row));
|
||||
cmd.appendJsonParams(getOpenedAtJSONParams(row));
|
||||
var queueData = getSaveTask(ctx, cmd);
|
||||
queueData.setFromChanges(true);
|
||||
let priority = null != opt_priority ? opt_priority : constants.QUEUE_PRIORITY_LOW;
|
||||
@ -1735,7 +1735,7 @@ exports.saveFromChanges = function(ctx, docId, statusInfo, optFormat, opt_userId
|
||||
cmd.setStatusInfoIn(statusInfo);
|
||||
cmd.setUserActionId(opt_userId);
|
||||
cmd.setUserActionIndex(opt_userIndex);
|
||||
cmd.setJsonParams(getOpenedAtJSONParams(row));
|
||||
cmd.appendJsonParams(getOpenedAtJSONParams(row));
|
||||
//todo lang and region are different
|
||||
cmd.setLCID(opt_userLcid);
|
||||
let userAuthStr = sqlBase.UserCallback.prototype.getCallbackByUserIndex(ctx, row.callback);
|
||||
|
||||
@ -183,8 +183,9 @@ function* convertByCmd(ctx, cmd, async, opt_fileTo, opt_taskExist, opt_priority,
|
||||
return status;
|
||||
}
|
||||
|
||||
async function convertFromChanges(ctx, docId, baseUrl, forceSave, externalChangeInfo, opt_userdata, opt_formdata, opt_userConnectionId,
|
||||
opt_userConnectionDocId, opt_responseKey, opt_priority, opt_expiration, opt_queue, opt_redisKey, opt_initShardKey) {
|
||||
async function convertFromChanges(ctx, docId, baseUrl, forceSave, externalChangeInfo, opt_userdata, opt_formdata,
|
||||
opt_userConnectionId, opt_userConnectionDocId, opt_responseKey, opt_priority,
|
||||
opt_expiration, opt_queue, opt_redisKey, opt_initShardKey, opt_jsonParams) {
|
||||
var cmd = new commonDefines.InputCommand();
|
||||
cmd.setCommand('sfcm');
|
||||
cmd.setDocId(docId);
|
||||
@ -217,6 +218,9 @@ async function convertFromChanges(ctx, docId, baseUrl, forceSave, externalChange
|
||||
if (opt_redisKey) {
|
||||
cmd.setRedisKey(opt_redisKey);
|
||||
}
|
||||
if (opt_jsonParams) {
|
||||
cmd.appendJsonParams(opt_jsonParams);
|
||||
}
|
||||
|
||||
let commandSfctByCmdRes = await canvasService.commandSfctByCmd(ctx, cmd, opt_priority, opt_expiration, opt_queue, opt_initShardKey);
|
||||
if (!commandSfctByCmdRes) {
|
||||
@ -314,7 +318,7 @@ function convertRequest(req, res, isJson) {
|
||||
jsonParams['watermark'] = params.watermark;
|
||||
}
|
||||
if (Object.keys(jsonParams).length > 0) {
|
||||
cmd.setJsonParams(JSON.stringify(jsonParams));
|
||||
cmd.appendJsonParams(jsonParams);
|
||||
}
|
||||
if (params.password) {
|
||||
if (params.password.length > constants.PASSWORD_MAX_LENGTH) {
|
||||
@ -538,18 +542,18 @@ function convertTo(req, res) {
|
||||
cmd.setLCID(utilsDocService.localeToLCID(lang));
|
||||
}
|
||||
if (fullSheetPreview) {
|
||||
cmd.setJsonParams(JSON.stringify({'spreadsheetLayout': {
|
||||
cmd.appendJsonParams({'spreadsheetLayout': {
|
||||
"ignorePrintArea": true,
|
||||
"fitToWidth": 1,
|
||||
"fitToHeight": 1
|
||||
}}));
|
||||
}});
|
||||
} else {
|
||||
cmd.setJsonParams(JSON.stringify({'spreadsheetLayout': {
|
||||
cmd.appendJsonParams({'spreadsheetLayout': {
|
||||
"ignorePrintArea": true,
|
||||
"fitToWidth": 0,
|
||||
"fitToHeight": 0,
|
||||
"scale": 100
|
||||
}}));
|
||||
}});
|
||||
}
|
||||
|
||||
fileTo = constants.OUTPUT_NAME;
|
||||
|
||||
@ -123,7 +123,7 @@ function TaskQueueDataConvert(ctx, task) {
|
||||
this.mailMergeSend = cmd.mailmergesend;
|
||||
this.thumbnail = cmd.thumbnail;
|
||||
this.textParams = cmd.getTextParams();
|
||||
this.jsonParams = cmd.getJsonParams();
|
||||
this.jsonParams = JSON.stringify(cmd.getJsonParams());
|
||||
this.lcid = cmd.getLCID();
|
||||
this.password = cmd.getPassword();
|
||||
this.savePassword = cmd.getSavePassword();
|
||||
|
||||
Reference in New Issue
Block a user