updates: only send email notifications when not auto-updating
fixes #749
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
get: get,
|
||||
ack: ack,
|
||||
getAllPaged: getAllPaged,
|
||||
get,
|
||||
ack,
|
||||
getAllPaged,
|
||||
|
||||
onEvent: onEvent,
|
||||
onEvent,
|
||||
|
||||
appUpdatesAvailable,
|
||||
boxUpdateAvailable,
|
||||
|
||||
// NOTE: if you add an alert, be sure to add title below
|
||||
ALERT_BACKUP_CONFIG: 'backupConfig',
|
||||
@@ -20,11 +23,13 @@ exports = module.exports = {
|
||||
_add: add
|
||||
};
|
||||
|
||||
let assert = require('assert'),
|
||||
let apps = require('./apps.js'),
|
||||
assert = require('assert'),
|
||||
async = require('async'),
|
||||
auditSource = require('./auditsource.js'),
|
||||
BoxError = require('./boxerror.js'),
|
||||
changelog = require('./changelog.js'),
|
||||
constants = require('./constants.js'),
|
||||
debug = require('debug')('box:notifications'),
|
||||
eventlog = require('./eventlog.js'),
|
||||
mailer = require('./mailer.js'),
|
||||
@@ -217,6 +222,39 @@ function appUpdated(eventId, app, callback) {
|
||||
}, callback);
|
||||
}
|
||||
|
||||
function boxUpdateAvailable(updateInfo, callback) {
|
||||
assert.strictEqual(typeof updateInfo, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
settings.getAutoupdatePattern(function (error, result) {
|
||||
if (error) return callback(error);
|
||||
|
||||
if (result !== constants.AUTOUPDATE_PATTERN_NEVER) return callback();
|
||||
|
||||
forEachAdmin({ skip: [] }, function (admin, done) {
|
||||
mailer.boxUpdateAvailable(admin.email, updateInfo, done);
|
||||
}, callback);
|
||||
});
|
||||
}
|
||||
|
||||
function appUpdatesAvailable(appUpdates, callback) {
|
||||
assert.strictEqual(typeof appUpdates, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
settings.getAutoupdatePattern(function (error, result) {
|
||||
if (error) return callback(error);
|
||||
|
||||
// if we are auto updating, then just consider apps that cannot be auto updated
|
||||
if (result !== constants.AUTOUPDATE_PATTERN_NEVER) appUpdates = appUpdates.filter(update => !apps.canAutoupdateApp(update.app, update.updateInfo));
|
||||
|
||||
if (appUpdates.length === 0) return callback();
|
||||
|
||||
forEachAdmin({ skip: [] }, function (admin, done) {
|
||||
mailer.appUpdatesAvailable(admin.email, appUpdates, done);
|
||||
}, callback);
|
||||
});
|
||||
}
|
||||
|
||||
function boxUpdated(eventId, oldVersion, newVersion, callback) {
|
||||
assert.strictEqual(typeof eventId, 'string');
|
||||
assert.strictEqual(typeof oldVersion, 'string');
|
||||
|
||||
Reference in New Issue
Block a user