[bug] Set interface lang as lcid for file assembling from changes; for bug 66926

This commit is contained in:
Sergey Konovalov
2024-04-04 13:34:23 +03:00
parent d8d285e753
commit 5373d62df4
6 changed files with 38 additions and 17 deletions

View File

@ -106,6 +106,7 @@ const cfgEditorDataStorage = config.get('services.CoAuthoring.server.editorDataS
const cfgEditorStatStorage = config.get('services.CoAuthoring.server.editorStatStorage');
const editorDataStorage = require('./' + cfgEditorDataStorage);
const editorStatStorage = require('./' + (cfgEditorStatStorage || cfgEditorDataStorage));
const utilsDocService = require("./utilsDocService");
const cfgEditSingleton = config.get('services.CoAuthoring.server.edit_singleton');
const cfgEditor = config.get('services.CoAuthoring.editor');
@ -933,7 +934,7 @@ async function startForceSave(ctx, docId, type, opt_userdata, opt_formdata, opt_
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);
let 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);
}
@ -990,8 +991,8 @@ async function startForceSave(ctx, docId, type, opt_userdata, opt_formdata, opt_
ctx.logger.debug('startForceSave end');
return res;
}
function getExternalChangeInfo(user, date) {
return {user_id: user.id, user_id_original: user.idOriginal, user_name: user.username, change_date: date};
function getExternalChangeInfo(user, date, lang) {
return {user_id: user.id, user_id_original: user.idOriginal, user_name: user.username, lang, change_date: date};
}
let resetForceSaveAfterChanges = co.wrap(function*(ctx, docId, newChangesLastTime, puckerIndex, baseUrl, changeInfo) {
const tenForceSaveEnable = ctx.getCfg('services.CoAuthoring.autoAssembly.enable', cfgForceSaveEnable);
@ -1323,7 +1324,7 @@ function* cleanDocumentOnExitNoChanges(ctx, docId, opt_userId, opt_userIndex, op
yield* cleanDocumentOnExit(ctx, docId, false, opt_userIndex);
}
function createSaveTimer(ctx, docId, opt_userId, opt_userIndex, opt_queue, opt_noDelay, opt_initShardKey) {
function createSaveTimer(ctx, docId, opt_userId, opt_userIndex, opt_userLcid, opt_queue, opt_noDelay, opt_initShardKey) {
return co(function*(){
const tenAscSaveTimeOutDelay = ctx.getCfg('services.CoAuthoring.server.savetimeoutdelay', cfgAscSaveTimeOutDelay);
@ -1341,7 +1342,7 @@ function createSaveTimer(ctx, docId, opt_userId, opt_userIndex, opt_queue, opt_n
}
while (true) {
if (!sqlBase.isLockCriticalSection(docId)) {
canvasService.saveFromChanges(ctx, docId, updateTask.statusInfo, null, opt_userId, opt_userIndex, opt_queue, opt_initShardKey);
canvasService.saveFromChanges(ctx, docId, updateTask.statusInfo, null, opt_userId, opt_userIndex, opt_userLcid, opt_queue, opt_initShardKey);
break;
}
yield utils.sleep(c_oAscLockTimeOutDelay);
@ -1853,7 +1854,8 @@ exports.install = function(server, callbackFunction) {
}
if (needSaveChanges && !conn.encrypted) {
// Send changes to save server
yield createSaveTimer(ctx, docId, tmpUser.idOriginal, userIndex);
let user_lcid = utilsDocService.localeToLCID(conn.lang);
yield createSaveTimer(ctx, docId, tmpUser.idOriginal, userIndex, user_lcid);
} else if (needSendStatus) {
yield* cleanDocumentOnExitNoChanges(ctx, docId, tmpUser.idOriginal, userIndex);
} else {
@ -2570,6 +2572,7 @@ exports.install = function(server, callbackFunction) {
}
conn.unsyncTime = null;
conn.encrypted = data.encrypted;
conn.lang = data.lang;
conn.supportAuthChangesAck = data.supportAuthChangesAck;
const c_LR = constants.LICENSE_RESULT;
@ -3237,7 +3240,7 @@ exports.install = function(server, callbackFunction) {
// Automatically remove the lock ourselves and send the index to save
yield* unSaveLock(ctx, conn, changesIndex, newChangesLastTime, puckerIndex);
//last save
let changeInfo = getExternalChangeInfo(conn.user, newChangesLastTime);
let changeInfo = getExternalChangeInfo(conn.user, newChangesLastTime, conn.lang);
yield resetForceSaveAfterChanges(ctx, docId, newChangesLastTime, puckerIndex, utils.getBaseUrlByConnection(ctx, conn), changeInfo);
} else {
let changesToSend = arrNewDocumentChanges;

View File

@ -830,6 +830,7 @@ function* commandSaveFromOrigin(ctx, cmd, outputData, password) {
if (docPassword.initial) {
cmd.setPassword(docPassword.initial);
}
//todo setLCID in browser
var queueData = getSaveTask(ctx, cmd);
queueData.setFromOrigin(true);
queueData.setFromChanges(true);
@ -864,7 +865,7 @@ function* commandSetPassword(ctx, conn, cmd, outputData) {
task.password = cmd.getPassword() || "";
let changeInfo = null;
if (conn.user) {
changeInfo = task.innerPasswordChange = docsCoServer.getExternalChangeInfo(conn.user, newChangesLastDate.getTime());
changeInfo = task.innerPasswordChange = docsCoServer.getExternalChangeInfo(conn.user, newChangesLastDate.getTime(), conn.lang);
}
var upsertRes = yield taskResult.updateIf(ctx, task, updateMask);
@ -1703,7 +1704,7 @@ exports.downloadFile = function(req, res) {
}
});
};
exports.saveFromChanges = function(ctx, docId, statusInfo, optFormat, opt_userId, opt_userIndex, opt_queue, opt_initShardKey) {
exports.saveFromChanges = function(ctx, docId, statusInfo, optFormat, opt_userId, opt_userIndex, opt_userLcid, opt_queue, opt_initShardKey) {
return co(function* () {
try {
var startDate = null;
@ -1729,6 +1730,8 @@ exports.saveFromChanges = function(ctx, docId, statusInfo, optFormat, opt_userId
cmd.setUserActionId(opt_userId);
cmd.setUserActionIndex(opt_userIndex);
cmd.setJsonParams(getOpenedAtJSONParams(row));
//todo lang and region are different
cmd.setLCID(opt_userLcid);
let userAuthStr = sqlBase.UserCallback.prototype.getCallbackByUserIndex(ctx, row.callback);
cmd.setWopiParams(wopiClient.parseWopiCallback(ctx, userAuthStr, row.callback));
addPasswordToCmd(ctx, cmd, row && row.password);

View File

@ -134,7 +134,7 @@ function shutdown() {
yield updateDoc(ctx, docId, commonDefines.FileStatus.Ok, "");
yield editorStat.addShutdown(redisKeyShutdown, docId);
ctx.logger.debug('shutdown createSaveTimerPromise %s', docId);
yield docsCoServer.createSaveTimer(ctx, docId, null, null, queue, true);
yield docsCoServer.createSaveTimer(ctx, docId, null, null, null, queue, true);
}
ctx.initDefault();
//sleep because of bugs in createSaveTimerPromise

View File

@ -35,7 +35,6 @@
const path = require('path');
var config = require('config');
var co = require('co');
const locale = require('windows-locale');
const mime = require('mime');
var taskResult = require('./taskresult');
var utils = require('./../../Common/sources/utils');
@ -50,6 +49,7 @@ var statsDClient = require('./../../Common/sources/statsdclient');
var storageBase = require('./../../Common/sources/storage-base');
var operationContext = require('./../../Common/sources/operationContext');
const sqlBase = require('./databaseConnectors/baseConnector');
const utilsDocService = require("./utilsDocService");
const cfgTokenEnableBrowser = config.get('services.CoAuthoring.token.enable.browser');
@ -193,6 +193,10 @@ async function convertFromChanges(ctx, docId, baseUrl, forceSave, externalChange
cmd.setDelimiter(commonDefines.c_oAscCsvDelimiter.Comma);
cmd.setForceSave(forceSave);
cmd.setExternalChangeInfo(externalChangeInfo);
if (externalChangeInfo.lang) {
//todo lang and region are different
cmd.setLCID(utilsDocService.localeToLCID(externalChangeInfo.lang));
}
if (opt_userdata) {
cmd.setUserData(opt_userdata);
}
@ -284,8 +288,8 @@ function convertRequest(req, res, isJson) {
cmd.setDelimiter(parseIntParam(params.delimiter) || commonDefines.c_oAscCsvDelimiter.Comma);
if(undefined != params.delimiterChar)
cmd.setDelimiterChar(params.delimiterChar);
if (params.region && locale[params.region.toLowerCase()]) {
cmd.setLCID(locale[params.region.toLowerCase()].id);
if (params.region) {
cmd.setLCID(utilsDocService.localeToLCID(params.region));
}
let jsonParams = {};
if (params.documentLayout) {
@ -518,8 +522,8 @@ function convertTo(req, res) {
cmd.setOutputFormat(outputFormat);
cmd.setCodepage(commonDefines.c_oAscCodePageUtf8);
cmd.setDelimiter(commonDefines.c_oAscCsvDelimiter.Comma);
if (lang && locale[lang.toLowerCase()]) {
cmd.setLCID(locale[lang.toLowerCase()].id);
if (lang) {
cmd.setLCID(utilsDocService.localeToLCID(lang));
}
if (fullSheetPreview) {
cmd.setJsonParams(JSON.stringify({'spreadsheetLayout': {

View File

@ -125,7 +125,7 @@ var checkDocumentExpire = function() {
var hasChanges = yield docsCoServer.hasChanges(ctx, docId);
if (hasChanges) {
//todo opt_initShardKey from getDocumentPresenceExpired data or from db
yield docsCoServer.createSaveTimer(ctx, docId, null, null, queue, true, true);
yield docsCoServer.createSaveTimer(ctx, docId, null, null, null, queue, true, true);
startSaveCount++;
} else {
yield docsCoServer.cleanDocumentOnExitNoChangesPromise(ctx, docId);

View File

@ -34,6 +34,7 @@
const exifParser = require("exif-parser");
const Jimp = require("jimp");
const locale = require('windows-locale');
async function fixImageExifRotation(ctx, buffer) {
if (!buffer) {
@ -59,7 +60,17 @@ async function fixImageExifRotation(ctx, buffer) {
}
return buffer;
}
/**
*
* @param {string} lang
* @returns {number | undefined}
*/
function localeToLCID(lang) {
let elem = locale[lang && lang.toLowerCase()];
return elem && elem.id;
}
module.exports = {
fixImageExifRotation
fixImageExifRotation,
localeToLCID
};