mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55: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.updateTopic(postData.tid);
|
||||||
Feed.updateRecent();
|
Feed.updateRecent();
|
||||||
|
|
||||||
db.searchIndex('post', postData.content, pid);
|
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();
|
callback();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -58,51 +58,69 @@ var winston = require('winston'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
ThreadTools.delete = function(tid, uid, callback) {
|
ThreadTools.delete = function(tid, uid, callback) {
|
||||||
topics.delete(tid);
|
topics.getTopicField(tid, 'deleted', function(err, deleted) {
|
||||||
|
if(err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
db.decrObjectField('global', 'topicCount');
|
if (parseInt(deleted, 10)) {
|
||||||
|
return callback(new Error('topic-already-deleted'));
|
||||||
|
}
|
||||||
|
|
||||||
ThreadTools.lock(tid);
|
topics.delete(tid);
|
||||||
|
|
||||||
db.searchRemove('topic', tid);
|
db.decrObjectField('global', 'topicCount');
|
||||||
|
|
||||||
events.logTopicDelete(uid, tid);
|
ThreadTools.lock(tid);
|
||||||
|
|
||||||
websockets.emitTopicPostStats();
|
db.searchRemove('topic', tid);
|
||||||
|
|
||||||
websockets.in('topic_' + tid).emit('event:topic_deleted', {
|
events.logTopicDelete(uid, tid);
|
||||||
tid: tid
|
|
||||||
});
|
websockets.emitTopicPostStats();
|
||||||
|
|
||||||
|
websockets.in('topic_' + tid).emit('event:topic_deleted', {
|
||||||
|
tid: tid
|
||||||
|
});
|
||||||
|
|
||||||
if (callback) {
|
|
||||||
callback(null, {
|
callback(null, {
|
||||||
tid: tid
|
tid: tid
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadTools.restore = function(tid, uid, callback) {
|
ThreadTools.restore = function(tid, uid, callback) {
|
||||||
topics.restore(tid);
|
topics.getTopicField(tid, 'deleted', function(err, deleted) {
|
||||||
db.incrObjectField('global', 'topicCount');
|
if(err) {
|
||||||
ThreadTools.unlock(tid);
|
return callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
events.logTopicRestore(uid, tid);
|
if (!parseInt(deleted, 10)) {
|
||||||
|
return callback(new Error('topic-already-restored'));
|
||||||
|
}
|
||||||
|
|
||||||
websockets.emitTopicPostStats();
|
topics.restore(tid);
|
||||||
|
|
||||||
websockets.in('topic_' + tid).emit('event:topic_restored', {
|
db.incrObjectField('global', 'topicCount');
|
||||||
tid: tid
|
|
||||||
});
|
|
||||||
|
|
||||||
topics.getTopicField(tid, 'title', function(err, title) {
|
ThreadTools.unlock(tid);
|
||||||
db.searchIndex('topic', title, tid);
|
|
||||||
});
|
events.logTopicRestore(uid, tid);
|
||||||
|
|
||||||
|
websockets.emitTopicPostStats();
|
||||||
|
|
||||||
|
websockets.in('topic_' + tid).emit('event:topic_restored', {
|
||||||
|
tid: tid
|
||||||
|
});
|
||||||
|
|
||||||
|
topics.getTopicField(tid, 'title', function(err, title) {
|
||||||
|
db.searchIndex('topic', title, tid);
|
||||||
|
});
|
||||||
|
|
||||||
if(callback) {
|
|
||||||
callback(null, {
|
callback(null, {
|
||||||
tid:tid
|
tid:tid
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadTools.lock = function(tid, uid, callback) {
|
ThreadTools.lock = function(tid, uid, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user