From bd0b5f4cdb8801a702d6c9567ad8a90a8d0d3b57 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Sat, 25 Jan 2014 22:43:49 -0500 Subject: [PATCH] more error checks in thread move --- src/threadTools.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/threadTools.js b/src/threadTools.js index 076c9b4b0b..201cf7afe8 100644 --- a/src/threadTools.js +++ b/src/threadTools.js @@ -187,9 +187,20 @@ var winston = require('winston'), ThreadTools.move = function(tid, cid, callback) { topics.getTopicFields(tid, ['cid', 'lastposttime'], function(err, topicData) { + if(err) { + return callback(err); + } + var oldCid = topicData.cid; + if(!oldCid) { + return callback(new Error('invalid-topic')); + } db.sortedSetRemove('categories:' + oldCid + ':tid', tid, function(err, result) { + if(err) { + return callback(err); + } + db.sortedSetAdd('categories:' + cid + ':tid', topicData.lastposttime, tid, function(err, result) { if(err) {