fixes removePostFromTopic

remove the pid from the votes set too
This commit is contained in:
barisusakli
2014-06-07 13:04:30 -04:00
parent bf04749f5e
commit b7f71ca0b4
2 changed files with 13 additions and 6 deletions

View File

@@ -15,15 +15,15 @@ var async = require('async'),
module.exports = function(Topics) {
Topics.createTopicFromPosts = function(uid, title, pids, callback) {
if(title) {
if (title) {
title = title.trim();
}
if(!title) {
if (!title) {
return callback(new Error('[[error:invalid-title]]'));
}
if(!pids || !pids.length) {
if (!pids || !pids.length) {
return callback(new Error('[[error:invalid-pid]]'));
}
@@ -39,12 +39,12 @@ module.exports = function(Topics) {
}
}, function(err, results) {
Topics.create({uid: results.postData.uid, title: title, cid: results.cid}, function(err, tid) {
if(err) {
if (err) {
return callback(err);
}
async.eachSeries(pids, move, function(err) {
if(err) {
if (err) {
return callback(err);
}

View File

@@ -131,7 +131,14 @@ module.exports = function(Topics) {
};
Topics.removePostFromTopic = function(tid, pid, callback) {
db.sortedSetRemove('tid:' + tid + ':posts', pid, callback);
async.parallel([
function (next) {
db.sortedSetRemove('tid:' + tid + ':posts', pid, next);
},
function (next) {
db.sortedSetRemove('tid:' + tid + ':posts:votes', pid, next);
}
], callback);
};
Topics.getPids = function(tid, callback) {