dont add tid to :tids:posts if its pinned

This commit is contained in:
Barış Soner Uşaklı
2016-12-21 23:49:50 +03:00
parent 61a58f2607
commit 805cacb2af
2 changed files with 16 additions and 10 deletions

View File

@@ -111,7 +111,7 @@ module.exports = function (Categories) {
Categories.onNewPostMade = function (cid, pinned, postData, callback) {
if (!cid || !postData) {
return callback();
return setImmediate(callback);
}
async.parallel([
@@ -123,17 +123,23 @@ module.exports = function (Categories) {
},
function (next) {
if (parseInt(pinned, 10) === 1) {
next();
} else {
db.sortedSetAdd('cid:' + cid + ':tids', postData.timestamp, postData.tid, next);
return setImmediate(next);
}
async.parallel([
function (next) {
db.sortedSetAdd('cid:' + cid + ':tids', postData.timestamp, postData.tid, next);
},
function (next) {
db.sortedSetIncrBy('cid:' + cid + ':tids:posts', 1, postData.tid, next);
}
], function (err) {
next(err);
});
},
function (next) {
Categories.updateRecentTid(cid, postData.tid, next);
},
function (next) {
db.sortedSetIncrBy('cid:' + cid + ':tids:posts', 1, postData.tid, next);
}
}
], callback);
};