Skip to content

Node.js based forum software built for the modern web

on pin remove from votes sorted set

Barış Soner Uşaklı2565b6e54228
diff --git a/src/topics/tools.js b/src/topics/tools.js
index 566fb62841..be87b8826f 100644
--- a/src/topics/tools.js
+++ b/src/topics/tools.js
@@ -179,12 +179,15 @@ module.exports = function (Topics) {
async.apply(db.sortedSetAdd, 'cid:' + topicData.cid + ':tids:pinned', Date.now(), tid),
async.apply(db.sortedSetRemove, 'cid:' + topicData.cid + ':tids', tid),
async.apply(db.sortedSetRemove, 'cid:' + topicData.cid + ':tids:posts', tid),
+ async.apply(db.sortedSetRemove, 'cid:' + topicData.cid + ':tids:votes', tid),
], next);
} else {
+ var votes = (parseInt(topicData.upvotes, 10) || 0) - (parseInt(topicData.downvotes, 10) || 0);
async.parallel([
async.apply(db.sortedSetRemove, 'cid:' + topicData.cid + ':tids:pinned', tid),
async.apply(db.sortedSetAdd, 'cid:' + topicData.cid + ':tids', topicData.lastposttime, tid),
async.apply(db.sortedSetAdd, 'cid:' + topicData.cid + ':tids:posts', topicData.postcount, tid),
+ async.apply(db.sortedSetAdd, 'cid:' + topicData.cid + ':tids:votes', votes, tid),
], next);
}
},