mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-20 00:30:25 +02:00
adding byPid zset for flags
This commit is contained in:
@@ -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
|
||||
}
|
||||
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) {
|
||||
|
||||
@@ -80,6 +80,14 @@ describe('Flags', function () {
|
||||
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 () {
|
||||
|
||||
Reference in New Issue
Block a user