update notification

This commit is contained in:
Girish Ramakrishnan
2019-03-07 13:34:46 -08:00
parent a9d6ac29f1
commit d2d9c4be6f
2 changed files with 6 additions and 13 deletions
+3 -1
View File
@@ -14,6 +14,7 @@ exports = module.exports = {
ALERT_DISK_SPACE: 'diskSpace',
ALERT_MAIL_STATUS: 'mailStatus',
ALERT_REBOOT: 'reboot',
ALERT_BOX_UPDATE: 'boxUpdate',
alert: alert,
@@ -40,7 +41,8 @@ const ALERT_TITLES = {
backupConfig: 'Backup configuration is unsafe',
diskSpace: 'Out of Disk Space',
mailStatus: 'Email is not configured properly',
reboot: 'Reboot Required'
reboot: 'Reboot Required',
boxUpdate: 'New Cloudron Update Available'
};
function NotificationsError(reason, errorOrMessage) {
+3 -12
View File
@@ -18,6 +18,7 @@ var apps = require('./apps.js'),
constants = require('./constants.js'),
debug = require('debug')('box:updatechecker'),
mailer = require('./mailer.js'),
notifications = require('./notifications.js'),
paths = require('./paths.js'),
safe = require('safetydance'),
settings = require('./settings.js');
@@ -160,19 +161,9 @@ function checkBoxUpdates(callback) {
callback();
}
// always send notifications if user is on the free plan
if (appstore.isFreePlan(result)) {
mailer.boxUpdateAvailable(false /* hasSubscription */, updateInfo.version, updateInfo.changelog);
return done();
}
const message = `Cloudron version ${updateInfo.version} is available. Click [here](/#/settings) to update.\n\nChangelog: ${updateInfo.changelog}`;
// only send notifications if update pattern is 'never'
settings.getBoxAutoupdatePattern(function (error, result) {
if (error) debug(error);
else if (result === constants.AUTOUPDATE_PATTERN_NEVER) mailer.boxUpdateAvailable(true /* hasSubscription */, updateInfo.version, updateInfo.changelog);
done();
});
notifications.alert(notifications.ALERT_BOX_UPDATE, message, done);
});
});
}