[bug] Change license notification message; For bug 70325

This commit is contained in:
Sergey Konovalov
2024-10-01 10:24:47 +03:00
parent c3aa709e38
commit eb2077cc31
4 changed files with 70 additions and 94 deletions

View File

@ -42,8 +42,9 @@
"email"
],
"template": {
"title": "License expiration",
"body": "%s license %s on %s!!!"
"title": "License expiration warning",
"bodyWarn": "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.",
"bodyError": "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": {
"repeatInterval": "1d"
@ -54,8 +55,8 @@
"email"
],
"template": {
"title": "License limit",
"body": "%s limit exceeded!!!"
"title": "License connection limit warning",
"body": "Attention! You have reached %s%% of the %s limit set by your license."
},
"policies": {
"repeatInterval": "1h"

View File

@ -52,7 +52,7 @@ const notificationTypes = {
class TransportInterface {
async send(ctx, message) {}
contentGeneration(template, messageParams) {}
contentGeneration(template, message) {}
}
class MailTransport extends TransportInterface {
@ -71,10 +71,10 @@ class MailTransport extends TransportInterface {
return mailService.send(this.host, this.auth.user, message);
}
contentGeneration(template, messageParams) {
contentGeneration(template, message) {
return {
subject: template.title,
text: util.format(template.body, ...messageParams)
text: message
};
}
}
@ -105,7 +105,7 @@ class Transport {
}
}
async function notify(ctx, notificationType, messageParams) {
async function notify(ctx, notificationType, message) {
const tenNotificationEnable = ctx.getCfg('notification.enable', cfgNotificationEnable);
if (!tenNotificationEnable) {
return;
@ -116,7 +116,7 @@ async function notify(ctx, notificationType, messageParams) {
if (tenRule) {
let checkRes = await checkRulePolicies(ctx, notificationType, tenRule);
if (checkRes) {
await notifyRule(ctx, tenRule, messageParams);
await notifyRule(ctx, tenRule, message);
}
}
}
@ -136,12 +136,12 @@ async function checkRulePolicies(ctx, notificationType, tenRule) {
return isLock;
}
async function notifyRule(ctx, tenRule, messageParams) {
async function notifyRule(ctx, tenRule, message) {
const transportObjects = tenRule.transportType.map(transport => new Transport(ctx, transport));
for (const transportObject of transportObjects) {
try {
const message = transportObject.transport.contentGeneration(tenRule.template, messageParams);
await transportObject.transport.send(ctx, message);
const mail = transportObject.transport.contentGeneration(tenRule.template, message);
await transportObject.transport.send(ctx, mail);
} catch (error) {
ctx.logger.error('Notification service: error: %s', error.stack);
}