eventlog: only merge ldap login events (and not dashboard)

fixes #758
This commit is contained in:
Girish Ramakrishnan
2021-01-06 22:09:37 -08:00
parent 624e34d02d
commit d15aa68bd7
2 changed files with 22 additions and 6 deletions
+19 -3
View File
@@ -2,6 +2,7 @@
exports = module.exports = {
add,
upsert,
get,
getAllPaged,
getByCreationTime,
@@ -91,9 +92,24 @@ function add(action, source, data, callback) {
callback = callback || NOOP_CALLBACK;
// we do only daily upserts for login actions, so they don't spam the db
var api = action === exports.ACTION_USER_LOGIN ? eventlogdb.upsert : eventlogdb.add;
api(uuid.v4(), action, source, data, function (error, id) {
eventlogdb.add(uuid.v4(), action, source, data, function (error, id) {
if (error) return callback(error);
callback(null, { id: id });
notifications.onEvent(id, action, source, data, NOOP_CALLBACK);
});
}
function upsert(action, source, data, callback) {
assert.strictEqual(typeof action, 'string');
assert.strictEqual(typeof source, 'object');
assert.strictEqual(typeof data, 'object');
assert(!callback || typeof callback === 'function');
callback = callback || NOOP_CALLBACK;
eventlogdb.upsert(uuid.v4(), action, source, data, function (error, id) {
if (error) return callback(error);
callback(null, { id: id });