From 8e31ec7199ea1364e26ce01d1211095e7fceed63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 26 May 2017 23:30:23 -0400 Subject: [PATCH] closes #5705 --- src/flags.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/flags.js b/src/flags.js index f752f9d4ea..14c6011691 100644 --- a/src/flags.js +++ b/src/flags.js @@ -342,6 +342,7 @@ Flags.create = function (type, id, uid, reason, timestamp, callback) { tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byPid:' + id, timestamp, flagId)); // by target pid if (targetUid) { tasks.push(async.apply(db.sortedSetIncrBy.bind(db), 'users:flags', 1, targetUid)); + tasks.push(async.apply(user.incrementUserFieldBy, targetUid, 'flags', 1)); } } @@ -543,19 +544,16 @@ Flags.getHistory = function (flagId, callback) { user.getUsersFields(uids, ['username', 'userslug', 'picture'], next); }, - ], function (err, users) { - if (err) { - return callback(err); - } + function (users, next) { + // Append user data to each history event + history = history.map(function (event, idx) { + event.user = users[idx]; + return event; + }); - // Append user data to each history event - history = history.map(function (event, idx) { - event.user = users[idx]; - return event; - }); - - callback(null, history); - }); + next(null, history); + }, + ], callback); }; Flags.appendHistory = function (flagId, uid, changeset, callback) {