Create notification for oom events

This commit is contained in:
Johannes Zellner
2019-01-07 12:57:57 +01:00
parent 77ac8d1e62
commit 86dbb1bdcf
2 changed files with 21 additions and 2 deletions

View File

@@ -9,7 +9,8 @@ exports = module.exports = {
getAllPaged: getAllPaged,
// specialized notifications
userAdded: userAdded
userAdded: userAdded,
oomEvent: oomEvent
};
var assert = require('assert'),
@@ -126,3 +127,20 @@ function userAdded(user, callback) {
}, callback);
});
}
function oomEvent(program, context, callback) {
assert.strictEqual(typeof program, 'string');
assert.strictEqual(typeof context, 'string');
assert(typeof callback === 'undefined' || typeof callback === 'function');
callback = callback || NOOP_CALLBACK;
users.getAllAdmins(function (error, result) {
if (error) return callback(new NotificationsError(NotificationsError.INTERNAL_ERROR, error));
async.each(result, function (admin, callback) {
mailer.oomEvent(program, context);
add(admin.id, program, context, '', callback);
}, callback);
});
}