From 596af5d82bd186025f9a3aceeee5152e3ea7019f Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 14 Jun 2016 10:07:39 +0300 Subject: [PATCH] closes #4754 --- src/topics/fork.js | 2 +- src/topics/posts.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/topics/fork.js b/src/topics/fork.js index dc8d66ab83..b2e16f069d 100644 --- a/src/topics/fork.js +++ b/src/topics/fork.js @@ -90,7 +90,7 @@ module.exports = function(Topics) { if (!exists) { return next(new Error('[[error:no-topic]]')); } - posts.getPostFields(pid, ['tid', 'uid', 'timestamp', 'votes'], next); + posts.getPostFields(pid, ['tid', 'uid', 'timestamp', 'upvotes', 'downvotes'], next); }, function(post, next) { if (!post || !post.tid) { diff --git a/src/topics/posts.js b/src/topics/posts.js index 671c65b4c5..6bdf103420 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -278,7 +278,10 @@ module.exports = function(Topics) { db.sortedSetAdd('tid:' + tid + ':posts', postData.timestamp, postData.pid, next); }, function(next) { - db.sortedSetAdd('tid:' + tid + ':posts:votes', postData.votes, postData.pid, next); + var upvotes = parseInt(postData.upvotes, 10) || 0; + var downvotes = parseInt(postData.downvotes, 10) || 0; + var votes = upvotes - downvotes; + db.sortedSetAdd('tid:' + tid + ':posts:votes', votes, postData.pid, next); } ], function(err) { next(err);