+19
-3
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user