mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 22:45:46 +01:00
closes #856
This commit is contained in:
@@ -207,18 +207,22 @@ var winston = require('winston'),
|
||||
});
|
||||
});
|
||||
|
||||
// Restore topic if it is the only post
|
||||
topics.getTopicField(postData.tid, 'postcount', function(err, count) {
|
||||
if (parseInt(count, 10) === 1) {
|
||||
threadTools.restore(postData.tid, uid);
|
||||
}
|
||||
});
|
||||
|
||||
Feed.updateTopic(postData.tid);
|
||||
Feed.updateRecent();
|
||||
|
||||
db.searchIndex('post', postData.content, pid);
|
||||
|
||||
// Restore topic if it is the only post
|
||||
topics.getTopicField(postData.tid, 'postcount', function(err, count) {
|
||||
if (parseInt(count, 10) === 1) {
|
||||
threadTools.restore(postData.tid, uid, function(err) {
|
||||
if(err) {
|
||||
winston.err(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -58,6 +58,15 @@ var winston = require('winston'),
|
||||
}
|
||||
|
||||
ThreadTools.delete = function(tid, uid, callback) {
|
||||
topics.getTopicField(tid, 'deleted', function(err, deleted) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (parseInt(deleted, 10)) {
|
||||
return callback(new Error('topic-already-deleted'));
|
||||
}
|
||||
|
||||
topics.delete(tid);
|
||||
|
||||
db.decrObjectField('global', 'topicCount');
|
||||
@@ -74,16 +83,26 @@ var winston = require('winston'),
|
||||
tid: tid
|
||||
});
|
||||
|
||||
if (callback) {
|
||||
callback(null, {
|
||||
tid: tid
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ThreadTools.restore = function(tid, uid, callback) {
|
||||
topics.getTopicField(tid, 'deleted', function(err, deleted) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!parseInt(deleted, 10)) {
|
||||
return callback(new Error('topic-already-restored'));
|
||||
}
|
||||
|
||||
topics.restore(tid);
|
||||
|
||||
db.incrObjectField('global', 'topicCount');
|
||||
|
||||
ThreadTools.unlock(tid);
|
||||
|
||||
events.logTopicRestore(uid, tid);
|
||||
@@ -98,11 +117,10 @@ var winston = require('winston'),
|
||||
db.searchIndex('topic', title, tid);
|
||||
});
|
||||
|
||||
if(callback) {
|
||||
callback(null, {
|
||||
tid:tid
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ThreadTools.lock = function(tid, uid, callback) {
|
||||
|
||||
Reference in New Issue
Block a user