mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
Merge branch release/v8.2.0 into develop
This commit is contained in:
@ -37,12 +37,12 @@
|
||||
"notification": {
|
||||
"rules": {
|
||||
"licenseExpirationWarning": {
|
||||
"enable": true,
|
||||
"enable": false,
|
||||
"transportType": [
|
||||
"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": {
|
||||
@ -63,12 +63,12 @@
|
||||
}
|
||||
},
|
||||
"licenseLimitEdit": {
|
||||
"enable": true,
|
||||
"enable": false,
|
||||
"transportType": [
|
||||
"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": {
|
||||
@ -76,12 +76,12 @@
|
||||
}
|
||||
},
|
||||
"licenseLimitLiveViewer": {
|
||||
"enable": true,
|
||||
"enable": false,
|
||||
"transportType": [
|
||||
"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": {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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');
|
||||
@ -3481,8 +3481,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) {
|
||||
@ -3533,14 +3533,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;
|
||||
@ -4257,7 +4259,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])}`;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user