Create notification for oom events
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user