mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
[bug] Customize notification title; fix bug 70772
This commit is contained in:
@ -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;
|
||||
|
||||
@ -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