Skip to content

Node.js based forum software built for the modern web

more error checks in thread move

Baris Soner Usaklibd0b5f4cdb88
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) {