various notification fixes

This commit is contained in:
Girish Ramakrishnan
2024-12-11 23:32:11 +01:00
parent fbe207dac3
commit be340580d4
10 changed files with 28 additions and 34 deletions
@@ -1,5 +1,3 @@
<%if (format === 'text') { %>
Dear Cloudron Admin,
The application '<%= title %>' installed at <%= appFqdn %> is not responding.
@@ -8,8 +6,9 @@ This is most likely a problem in the application.
To resolve this, you can try the following:
* Check the app logs - https://docs.cloudron.io/apps/#log-viewer
* Restart the app by opening the app's web terminal - https://docs.cloudron.io/apps/#web-terminal
* Restore the app to the latest backup - https://docs.cloudron.io/backups/#restoring-an-app
* Check the troubleshooting guidelines - https://docs.cloudron.io/troubleshooting/#unresponsive-app
* Contact us in our Forum at https://forum.cloudron.io
Powered by https://cloudron.io
@@ -18,6 +17,3 @@ Don't want such mails? Change your notification preferences at <%= notifications
Sent at: <%= new Date().toUTCString() %>
<% } else { %>
<% } %>
+11
View File
@@ -0,0 +1,11 @@
Dear Cloudron Admin,
The application '<%= title %>' installed at <%= appFqdn %> is back online
and responding to health checks.
Powered by https://cloudron.io
Don't want such mails? Change your notification preferences at <%= notificationsUrl %>
Sent at: <%= new Date().toUTCString() %>
@@ -1,5 +1,3 @@
<%if (format === 'text') { %>
Dear <%= cloudronName %> Admin,
Cloudron failed to create a complete backup. Please see the logs at <%= logUrl %> for more information.
@@ -17,7 +15,3 @@ Don't want such mails? Change your notification preferences at <%= notifications
Sent at: <%= new Date().toUTCString() %>
<% } else { %>
<% } %>
@@ -1,5 +1,3 @@
<%if (format === 'text') { %>
Dear Cloudron Admin,
The certificate for <%= domain %> could not be renewed.
@@ -27,6 +25,3 @@ Don't want such mails? Change your notification preferences at <%= notifications
Sent at: <%= new Date().toUTCString() %>
<% } else { %>
<% } %>
@@ -1,5 +1,3 @@
<%if (format === 'text') { %>
Dear <%= cloudronName %> Admin,
<%if (app) { %>
@@ -24,6 +22,3 @@ Don't want such mails? Change your notification preferences at <%= notifications
Sent at: <%= new Date().toUTCString() %>
<% } else { %>
<% } %>
+8 -8
View File
@@ -195,7 +195,7 @@ async function appDown(mailTo, app) {
from: mailConfig.notificationFrom,
to: mailTo,
subject: `[${mailConfig.cloudronName}] App ${app.fqdn} is down`,
text: render('app_down.ejs', { title: app.manifest.title, appFqdn: app.fqdn, notificationsUrl: mailConfig.notificationsUrl })
text: render('app_down-text.ejs', { title: app.manifest.title, appFqdn: app.fqdn, notificationsUrl: mailConfig.notificationsUrl })
};
await sendMail(mailOptions);
@@ -211,17 +211,17 @@ async function appUp(mailTo, app) {
from: mailConfig.notificationFrom,
to: mailTo,
subject: `[${mailConfig.cloudronName}] App ${app.fqdn} is back online`,
text: render('app_up.ejs', { title: app.manifest.title, appFqdn: app.fqdn, notificationsUrl: mailConfig.notificationsUrl })
text: render('app_up-text.ejs', { title: app.manifest.title, appFqdn: app.fqdn, notificationsUrl: mailConfig.notificationsUrl })
};
await sendMail(mailOptions);
}
async function oomEvent(mailTo, app, addon, containerId, event) {
async function oomEvent(mailTo, containerId, app, addon, event) {
assert.strictEqual(typeof mailTo, 'string');
assert.strictEqual(typeof containerId, 'string');
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof addon, 'object');
assert.strictEqual(typeof containerId, 'string');
assert.strictEqual(typeof event, 'object');
const mailConfig = await getMailConfig();
@@ -239,7 +239,7 @@ async function oomEvent(mailTo, app, addon, containerId, event) {
from: mailConfig.notificationFrom,
to: mailTo,
subject: `[${mailConfig.cloudronName}] ${app ? app.fqdn : addon.name} was restarted (OOM)`,
text: render('oom_event.ejs', templateData)
text: render('oom_event-text.ejs', templateData)
};
await sendMail(mailOptions);
@@ -256,7 +256,7 @@ async function backupFailed(mailTo, errorMessage, logUrl) {
from: mailConfig.notificationFrom,
to: mailTo,
subject: `[${mailConfig.cloudronName}] Failed to backup`,
text: render('backup_failed.ejs', { cloudronName: mailConfig.cloudronName, message: errorMessage, logUrl, notificationsUrl: mailConfig.notificationsUrl })
text: render('backup_failed-text.ejs', { cloudronName: mailConfig.cloudronName, message: errorMessage, logUrl, notificationsUrl: mailConfig.notificationsUrl })
};
await sendMail(mailOptions);
@@ -273,7 +273,7 @@ async function certificateRenewalError(mailTo, domain, message) {
from: mailConfig.notificationFrom,
to: mailTo,
subject: `[${mailConfig.cloudronName}] Certificate renewal error`,
text: render('certificate_renewal_error.ejs', { domain, message, notificationsUrl: mailConfig.notificationsUrl })
text: render('certificate_renewal_error-text.ejs', { domain, message, notificationsUrl: mailConfig.notificationsUrl })
};
await sendMail(mailOptions);
@@ -290,7 +290,7 @@ async function sendTestMail(domain, email) {
from: `"${mailConfig.cloudronName}" <no-reply@${domain}>`,
to: email,
subject: `[${mailConfig.cloudronName}] Test Email`,
text: render('test.ejs', { cloudronName: mailConfig.cloudronName}),
text: render('test-text.ejs', { cloudronName: mailConfig.cloudronName}),
html: render('test-html.ejs', { cloudronName: mailConfig.cloudronName })
};
+5 -3
View File
@@ -63,6 +63,8 @@ async function add(type, title, message, data) {
assert.strictEqual(typeof message, 'string');
assert.strictEqual(typeof data, 'object');
debug(`add: ${type} ${title}`);
const query = 'INSERT INTO notifications (type, title, message, acknowledged, eventId, context) VALUES (?, ?, ?, ?, ?, ?)';
const args = [ type, title, message, false, data?.eventId || null, data.context || '' ];
@@ -137,7 +139,7 @@ async function list(filters, page, perPage) {
return results;
}
async function oomEvent(eventId, containerId, app, addonName /*, event*/) {
async function oomEvent(eventId, containerId, app, addonName, event) {
assert.strictEqual(typeof eventId, 'string');
assert.strictEqual(typeof containerId, 'string');
assert.strictEqual(typeof app, 'object');
@@ -164,7 +166,7 @@ async function oomEvent(eventId, containerId, app, addonName /*, event*/) {
const admins = await users.getAdmins();
for (const admin of admins) {
if (admin.notificationConfig.includes(exports.TYPE_APP_OOM)) {
await mailer.oomEvent(admin.email, app, addonName);
await mailer.oomEvent(admin.email, containerId, app, addonName, event);
}
}
}
@@ -176,7 +178,7 @@ async function appUp(eventId, app) {
const admins = await users.getAdmins();
for (const admin of admins) {
if (admin.notificationConfig.includes(exports.TYPE_APP_UP)) {
await mailer.appDown(admin.email, app);
await mailer.appUp(admin.email, app);
}
}
}