mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-07 04:51:26 +01:00
fixes removePostFromTopic
remove the pid from the votes set too
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user