notifications: fix update notification

the notification wasn't working because this was in apptask and the apptask died
before it could send out the email. we now move the notification to box process
and also remove the email notification.
This commit is contained in:
Girish Ramakrishnan
2021-04-19 14:22:22 -07:00
parent 3ab0a25ec9
commit 355de5b0a4
8 changed files with 60 additions and 169 deletions

View File

@@ -7,8 +7,6 @@ exports = module.exports = {
sendInvite,
appUpdated,
backupFailed,
certificateRenewalError,
@@ -174,45 +172,6 @@ function passwordReset(user) {
});
}
function appUpdated(mailTo, app, callback) {
assert.strictEqual(typeof mailTo, 'string');
assert.strictEqual(typeof app, 'object');
callback = callback || NOOP_CALLBACK;
debug('Sending mail for app %s @ %s updated', app.id, app.fqdn);
getMailConfig(function (error, mailConfig) {
if (error) return debug('Error getting mail details:', error);
var converter = new showdown.Converter();
var templateData = {
title: app.manifest.title,
appFqdn: app.fqdn,
version: app.manifest.version,
changelog: app.manifest.changelog,
changelogHTML: converter.makeHtml(app.manifest.changelog),
cloudronName: mailConfig.cloudronName,
cloudronAvatarUrl: settings.adminOrigin() + '/api/v1/cloudron/avatar'
};
var templateDataText = JSON.parse(JSON.stringify(templateData));
templateDataText.format = 'text';
var templateDataHTML = JSON.parse(JSON.stringify(templateData));
templateDataHTML.format = 'html';
var mailOptions = {
from: mailConfig.notificationFrom,
to: mailTo,
subject: `[${mailConfig.cloudronName}] App ${app.fqdn} was updated`,
text: render('app_updated.ejs', templateDataText),
html: render('app_updated.ejs', templateDataHTML)
};
sendMail(mailOptions, callback);
});
}
function boxUpdateAvailable(mailTo, updateInfo, callback) {
assert.strictEqual(typeof mailTo, 'string');
assert.strictEqual(typeof updateInfo, 'object');