wait for state to be updated

v1.18.x
Barış Soner Uşaklı 7 years ago
parent fd2a49fd1f
commit 67bc58f04c

@ -370,9 +370,11 @@ Flags.create = function (type, id, uid, reason, timestamp, callback) {
if (targetUid) { if (targetUid) {
tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byTargetUid:' + targetUid, timestamp, flagId)); // by target uid tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byTargetUid:' + targetUid, timestamp, flagId)); // by target uid
} }
if (targetCid) { if (targetCid) {
tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byCid:' + targetCid, timestamp, flagId)); // by target cid tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byCid:' + targetCid, timestamp, flagId)); // by target cid
} }
if (type === 'post') { if (type === 'post') {
tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byPid:' + id, timestamp, flagId)); // by target pid tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byPid:' + id, timestamp, flagId)); // by target pid
if (targetUid) { if (targetUid) {
@ -381,16 +383,12 @@ Flags.create = function (type, id, uid, reason, timestamp, callback) {
} }
} }
async.parallel(tasks, function (err) {
if (err) {
return next(err);
}
if (doHistoryAppend) { if (doHistoryAppend) {
Flags.update(flagId, uid, { state: 'open' }); tasks.push(async.apply(Flags.update, flagId, uid, { state: 'open' }));
} }
next(null, flagId); async.parallel(tasks, function (err) {
next(err, flagId);
}); });
}, },
async.apply(Flags.get), async.apply(Flags.get),

Loading…
Cancel
Save