Trigger user notifications through eventlog api only

This commit is contained in:
Johannes Zellner
2019-01-17 13:12:26 +01:00
parent 8aaa671412
commit b9c3e85f89
3 changed files with 33 additions and 29 deletions

View File

@@ -56,6 +56,7 @@ var assert = require('assert'),
DatabaseError = require('./databaseerror.js'),
debug = require('debug')('box:eventlog'),
eventlogdb = require('./eventlogdb.js'),
notifications = require('./notifications.js'),
util = require('util'),
uuid = require('uuid');
@@ -96,6 +97,17 @@ function add(action, source, data, callback) {
eventlogdb.add(id, action, source, data, function (error) {
if (error) return callback(new EventLogError(EventLogError.INTERNAL_ERROR, error));
// decide if we want to add notifications as well
if (action === exports.ACTION_USER_ADD) {
notifications.userAdded(data.user);
} if (action === exports.ACTION_USER_REMOVE) {
notifications.userRemoved(data.user);
} if (action === exports.ACTION_USER_UPDATE && data.adminStatusChanged) {
notifications.adminChanged(data.user);
} else {
// no notification
}
callback(null, { id: id });
});
}