From a566d5982a7f6723ce97986c909c5431cffca584 Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Wed, 9 Oct 2024 08:53:56 +0300 Subject: [PATCH 1/4] [bug] Fix 'command' path in proxyCommand --- DocService/sources/DocsCoServer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DocService/sources/DocsCoServer.js b/DocService/sources/DocsCoServer.js index e1ad2203..ca1a090c 100644 --- a/DocService/sources/DocsCoServer.js +++ b/DocService/sources/DocsCoServer.js @@ -4254,7 +4254,7 @@ async function proxyCommand(ctx, req, params) { //todo gen shardkey as in sdkjs const shardkey = params.key; const baseUrl = utils.getBaseUrlByRequest(ctx, req); - let url = `${baseUrl}/coauthoring/command?&${constants.SHARD_KEY_API_NAME}=${encodeURIComponent(shardkey)}`; + let url = `${baseUrl}/command?&${constants.SHARD_KEY_API_NAME}=${encodeURIComponent(shardkey)}`; for (let name in req.query) { url += `&${name}=${encodeURIComponent(req.query[name])}`; } From 2652dd20c54664d8d0408bf66a9150b1771a2045 Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Thu, 10 Oct 2024 13:36:42 +0300 Subject: [PATCH 2/4] [config] Turn off notification by default; Fix bug 70807 --- Common/config/default.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Common/config/default.json b/Common/config/default.json index 3237f89d..25e15428 100644 --- a/Common/config/default.json +++ b/Common/config/default.json @@ -37,7 +37,7 @@ "notification": { "rules": { "licenseExpirationWarning": { - "enable": true, + "enable": false, "transportType": [ "email" ], @@ -63,7 +63,7 @@ } }, "licenseLimitEdit": { - "enable": true, + "enable": false, "transportType": [ "email" ], @@ -76,7 +76,7 @@ } }, "licenseLimitLiveViewer": { - "enable": true, + "enable": false, "transportType": [ "email" ], From 199e8f9f5e8f248049584002b75b405c273bd98f Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Thu, 10 Oct 2024 14:29:27 +0300 Subject: [PATCH 3/4] [bug] Customize notification title; fix bug 70772 --- Common/config/default.json | 8 ++++---- Common/sources/notificationService.js | 14 +++++++------- DocService/sources/DocsCoServer.js | 14 ++++++++------ DocService/sources/utilsDocService.js | 19 +++++++++++-------- 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/Common/config/default.json b/Common/config/default.json index 25e15428..4c04dc00 100644 --- a/Common/config/default.json +++ b/Common/config/default.json @@ -42,7 +42,7 @@ "email" ], "template": { - "title": "License expiration warning", + "title": "%s Docs license expiration warning", "body": "Attention! Your license is about to expire on %s.\nUpon reaching this date, you will no longer be entitled to receive personal technical support and install new Docs versions released after this date." }, "policies": { @@ -55,7 +55,7 @@ "email" ], "template": { - "title": "License expiration warning", + "title": "%s Docs license expiration warning", "body": "Attention! Your license expired on %s.\nYou are no longer entitled to receive personal technical support and install new Docs versions released after this date.\nPlease contact sales@onlyoffice.com to discuss license renewal." }, "policies": { @@ -68,7 +68,7 @@ "email" ], "template": { - "title": "License connection limit warning", + "title": "%s Docs license connection limit warning", "body": "Attention! You have reached %s%% of the %s limit set by your license." }, "policies": { @@ -81,7 +81,7 @@ "email" ], "template": { - "title": "License connection limit warning", + "title": "%s Docs license connection limit warning", "body": "Attention! You have reached %s%% of the live viewer %s limit set by your license." }, "policies": { diff --git a/Common/sources/notificationService.js b/Common/sources/notificationService.js index ad442b2e..afb146a5 100644 --- a/Common/sources/notificationService.js +++ b/Common/sources/notificationService.js @@ -53,7 +53,7 @@ const notificationTypes = { class TransportInterface { async send(ctx, message) {} - contentGeneration(template, message) {} + contentGeneration(title, message) {} } class MailTransport extends TransportInterface { @@ -72,9 +72,9 @@ class MailTransport extends TransportInterface { return mailService.send(this.host, this.auth.user, message); } - contentGeneration(template, message) { + contentGeneration(title, message) { return { - subject: template.title, + subject: title, text: message }; } @@ -106,13 +106,13 @@ class Transport { } } -async function notify(ctx, notificationType, message, opt_cacheKey = undefined) { +async function notify(ctx, notificationType, title, message, opt_cacheKey = undefined) { const tenRule = ctx.getCfg(`notification.rules.${notificationType}`, config.get(`notification.rules.${notificationType}`)); if (tenRule?.enable) { ctx.logger.debug('Notification service: notify "%s"', notificationType); let checkRes = await checkRulePolicies(ctx, notificationType, tenRule, opt_cacheKey); if (checkRes) { - await notifyRule(ctx, tenRule, message); + await notifyRule(ctx, tenRule, title, message); } } } @@ -132,11 +132,11 @@ async function checkRulePolicies(ctx, notificationType, tenRule, opt_cacheKey) { return isLock; } -async function notifyRule(ctx, tenRule, message) { +async function notifyRule(ctx, tenRule, title, message) { const transportObjects = tenRule.transportType.map(transport => new Transport(ctx, transport)); for (const transportObject of transportObjects) { try { - const mail = transportObject.transport.contentGeneration(tenRule.template, message); + const mail = transportObject.transport.contentGeneration(title, message); await transportObject.transport.send(ctx, mail); } catch (error) { ctx.logger.error('Notification service: error: %s', error.stack); diff --git a/DocService/sources/DocsCoServer.js b/DocService/sources/DocsCoServer.js index ca1a090c..4fd1a395 100644 --- a/DocService/sources/DocsCoServer.js +++ b/DocService/sources/DocsCoServer.js @@ -138,8 +138,8 @@ const cfgForgottenFiles = config.get('services.CoAuthoring.server.forgottenfiles const cfgForgottenFilesName = config.get('services.CoAuthoring.server.forgottenfilesname'); const cfgMaxRequestChanges = config.get('services.CoAuthoring.server.maxRequestChanges'); const cfgWarningLimitPercents = config.get('license.warning_limit_percents'); -const cfgNotificationRuleLicenseLimitEdit = config.get('notification.rules.licenseLimitEdit.template.body'); -const cfgNotificationRuleLicenseLimitLiveViewer = config.get('notification.rules.licenseLimitLiveViewer.template.body'); +const cfgNotificationRuleLicenseLimitEdit = config.get('notification.rules.licenseLimitEdit.template'); +const cfgNotificationRuleLicenseLimitLiveViewer = config.get('notification.rules.licenseLimitLiveViewer.template'); const cfgErrorFiles = config.get('FileConverter.converter.errorfiles'); const cfgOpenProtectedFile = config.get('services.CoAuthoring.server.openProtectedFile'); const cfgIsAnonymousSupport = config.get('services.CoAuthoring.server.isAnonymousSupport'); @@ -3479,8 +3479,8 @@ exports.install = function(server, callbackFunction) { function* _checkLicenseAuth(ctx, licenseInfo, userId, isLiveViewer) { const tenWarningLimitPercents = ctx.getCfg('license.warning_limit_percents', cfgWarningLimitPercents) / 100; - const tenNotificationRuleLicenseLimitEdit = ctx.getCfg(`notification.rules.licenseLimitEdit.template.body`, cfgNotificationRuleLicenseLimitEdit); - const tenNotificationRuleLicenseLimitLiveViewer = ctx.getCfg(`notification.rules.licenseLimitLiveViewer.template.body`, cfgNotificationRuleLicenseLimitLiveViewer); + const tenNotificationRuleLicenseLimitEdit = ctx.getCfg(`notification.rules.licenseLimitEdit.template`, cfgNotificationRuleLicenseLimitEdit); + const tenNotificationRuleLicenseLimitLiveViewer = ctx.getCfg(`notification.rules.licenseLimitLiveViewer.template`, cfgNotificationRuleLicenseLimitLiveViewer); const c_LR = constants.LICENSE_RESULT; let licenseType = licenseInfo.type; if (c_LR.Success === licenseType || c_LR.SuccessLimit === licenseType) { @@ -3531,14 +3531,16 @@ exports.install = function(server, callbackFunction) { } } if ((c_LR.Success !== licenseType && c_LR.SuccessLimit !== licenseType) || 100 !== notificationPercent) { - const message = util.format(notificationTemplate, notificationPercent, notificationLimit); + const applicationName = (process.env.APPLICATION_NAME || "").toUpperCase(); + const title = util.format(notificationTemplate.title, applicationName); + const message = util.format(notificationTemplate.body, notificationPercent, notificationLimit); if (100 !== notificationPercent) { ctx.logger.warn(message); } else { ctx.logger.error(message); } //todo with yield service could throw error - void notificationService.notify(ctx, notificationType, message, notificationType + notificationPercent); + void notificationService.notify(ctx, notificationType, title, message, notificationType + notificationPercent); } } return licenseType; diff --git a/DocService/sources/utilsDocService.js b/DocService/sources/utilsDocService.js index b11ce5df..e5f42a20 100644 --- a/DocService/sources/utilsDocService.js +++ b/DocService/sources/utilsDocService.js @@ -43,8 +43,8 @@ const tenantManager = require('../../Common/sources/tenantManager'); const { notificationTypes, ...notificationService } = require('../../Common/sources/notificationService'); const cfgStartNotifyFrom = ms(config.get('license.warning_license_expiration')); -const cfgNotificationRuleLicenseExpirationWarning = config.get('notification.rules.licenseExpirationWarning.template.body'); -const cfgNotificationRuleLicenseExpirationError = config.get('notification.rules.licenseExpirationError.template.body'); +const cfgNotificationRuleLicenseExpirationWarning = config.get('notification.rules.licenseExpirationWarning.template'); +const cfgNotificationRuleLicenseExpirationError = config.get('notification.rules.licenseExpirationError.template'); async function fixImageExifRotation(ctx, buffer) { if (!buffer) { @@ -130,16 +130,19 @@ async function notifyLicenseExpiration(ctx, endDate) { endDate = currentDate; } const formattedExpirationTime = humanFriendlyExpirationTime(endDate); + const applicationName = (process.env.APPLICATION_NAME || "").toUpperCase(); if (endDate <= currentDate) { - const tenNotificationRuleLicenseExpirationError = ctx.getCfg('notification.rules.licenseExpirationError.template.body', cfgNotificationRuleLicenseExpirationError); - const message = util.format(tenNotificationRuleLicenseExpirationError, formattedExpirationTime); + const tenNotificationRuleLicenseExpirationError = ctx.getCfg('notification.rules.licenseExpirationError.template', cfgNotificationRuleLicenseExpirationError); + const title = util.format(tenNotificationRuleLicenseExpirationError.title, applicationName); + const message = util.format(tenNotificationRuleLicenseExpirationError.body, formattedExpirationTime); ctx.logger.error(message); - await notificationService.notify(ctx, notificationTypes.LICENSE_EXPIRATION_ERROR, message); + await notificationService.notify(ctx, notificationTypes.LICENSE_EXPIRATION_ERROR, title, message); } else { - const tenNotificationRuleLicenseExpirationWarning = ctx.getCfg('notification.rules.licenseExpirationWarning.template.body', cfgNotificationRuleLicenseExpirationWarning); - const message = util.format(tenNotificationRuleLicenseExpirationWarning, formattedExpirationTime); + const tenNotificationRuleLicenseExpirationWarning = ctx.getCfg('notification.rules.licenseExpirationWarning.template', cfgNotificationRuleLicenseExpirationWarning); + const title = util.format(tenNotificationRuleLicenseExpirationWarning.title, applicationName); + const message = util.format(tenNotificationRuleLicenseExpirationWarning.body, formattedExpirationTime); ctx.logger.warn(message); - await notificationService.notify(ctx, notificationTypes.LICENSE_EXPIRATION_WARNING, message); + await notificationService.notify(ctx, notificationTypes.LICENSE_EXPIRATION_WARNING, title, message); } } } From b2ea17e23728c01d48f14001db63eedf6f0fa4eb Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Sat, 12 Oct 2024 22:41:12 +0300 Subject: [PATCH 4/4] [bug] Fix crash in commandSetPassword after fix of 70466; fix bug 70864 --- DocService/sources/canvasservice.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/DocService/sources/canvasservice.js b/DocService/sources/canvasservice.js index 3e84ebdb..8783f80c 100644 --- a/DocService/sources/canvasservice.js +++ b/DocService/sources/canvasservice.js @@ -880,9 +880,11 @@ function* commandSetPassword(ctx, conn, cmd, outputData) { let documentPasswordCurEnc = sqlBase.DocumentPassword.prototype.getCurPassword(ctx, row.password); if (documentPasswordCurEnc) { hasDocumentPassword = true; - const passwordCurPlain = yield utils.decryptPassword(ctx, documentPasswordCurEnc); - const passwordPlain = yield utils.decryptPassword(ctx, cmd.getPassword()); - isDocumentPasswordModified = passwordCurPlain !== passwordPlain; + if (cmd.getPassword()) { + const passwordCurPlain = yield utils.decryptPassword(ctx, documentPasswordCurEnc); + const passwordPlain = yield utils.decryptPassword(ctx, cmd.getPassword()); + isDocumentPasswordModified = passwordCurPlain !== passwordPlain; + } } } }