updates: only send email notifications when not auto-updating
fixes #749
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
passwordReset: passwordReset,
|
||||
appUpdatesAvailable: appUpdatesAvailable,
|
||||
passwordReset,
|
||||
boxUpdateAvailable,
|
||||
appUpdatesAvailable,
|
||||
|
||||
sendInvite: sendInvite,
|
||||
sendInvite,
|
||||
|
||||
appUp: appUp,
|
||||
appDied: appDied,
|
||||
appUpdated: appUpdated,
|
||||
oomEvent: oomEvent,
|
||||
appUp,
|
||||
appDied,
|
||||
appUpdated,
|
||||
oomEvent,
|
||||
|
||||
backupFailed: backupFailed,
|
||||
backupFailed,
|
||||
|
||||
certificateRenewalError: certificateRenewalError,
|
||||
boxUpdateError: boxUpdateError,
|
||||
certificateRenewalError,
|
||||
boxUpdateError,
|
||||
|
||||
sendTestMail: sendTestMail,
|
||||
sendTestMail,
|
||||
|
||||
_mailQueue: [] // accumulate mails in test mode
|
||||
};
|
||||
@@ -256,6 +257,43 @@ function appUpdated(mailTo, app, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function boxUpdateAvailable(mailTo, updateInfo, callback) {
|
||||
assert.strictEqual(typeof mailTo, 'string');
|
||||
assert.strictEqual(typeof updateInfo, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
getMailConfig(function (error, mailConfig) {
|
||||
if (error) return debug('Error getting mail details:', error);
|
||||
|
||||
var converter = new showdown.Converter();
|
||||
|
||||
var templateData = {
|
||||
webadminUrl: settings.adminOrigin(),
|
||||
newBoxVersion: updateInfo.version,
|
||||
changelog: updateInfo.changelog,
|
||||
changelogHTML: updateInfo.changelog.map(function (e) { return converter.makeHtml(e); }),
|
||||
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: 'Cloudron update available',
|
||||
text: render('box_update_available.ejs', templateDataText),
|
||||
html: render('box_update_available.ejs', templateDataHTML)
|
||||
};
|
||||
|
||||
sendMail(mailOptions, callback);
|
||||
});
|
||||
}
|
||||
|
||||
function appUpdatesAvailable(mailTo, apps, callback) {
|
||||
assert.strictEqual(typeof mailTo, 'string');
|
||||
assert.strictEqual(typeof apps, 'object');
|
||||
@@ -285,7 +323,7 @@ function appUpdatesAvailable(mailTo, apps, callback) {
|
||||
var mailOptions = {
|
||||
from: mailConfig.notificationFrom,
|
||||
to: mailTo,
|
||||
subject: `New app updates available for ${mailConfig.cloudronName}`,
|
||||
subject: 'App updates available',
|
||||
text: render('app_updates_available.ejs', templateDataText),
|
||||
html: render('app_updates_available.ejs', templateDataHTML)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user