adding byPid zset for flags

v1.18.x
Julian Lam 8 years ago
parent f58107e40a
commit 10f270d016

@ -336,7 +336,10 @@ Flags.create = function (type, id, uid, reason, timestamp, callback) {
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 uid tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byCid:' + targetCid, timestamp, flagId)); // by target cid
}
if (type === 'post') {
tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byPid:' + id, timestamp, flagId)); // by target pid
} }
async.parallel(tasks, function (err, data) { async.parallel(tasks, function (err, data) {

@ -80,6 +80,14 @@ describe('Flags', function () {
done(); done();
}); });
}); });
it('should add the flag to the byPid zset for pid 1 if it is of type post', function (done) {
db.isSortedSetMember('flags:byPid:' + 1, 1, function (err, isMember) {
assert.ifError(err);
assert.ok(isMember);
done();
});
});
}); });
describe('.exists()', function () { describe('.exists()', function () {

Loading…
Cancel
Save