if every post gets deleted in a topic, then the topic deletes itself also

This commit is contained in:
Julian Lam
2013-07-15 15:25:31 -04:00
parent 87aec422e9
commit 561ff38e5a
3 changed files with 25 additions and 14 deletions

View File

@@ -88,6 +88,15 @@ marked.setOptions({
io.sockets.in('topic_' + tid).emit('event:post_deleted', {
pid: pid
});
// Delete the thread if it is the last undeleted post
threadTools.get_latest_undeleted_pid(tid, function(err, pid) {
if (err && err.message === 'no-undeleted-pids-found') {
threadTools.delete(tid, -1, function(err) {
if (err) console.log('Error: Could not delete topic (tid: ' + tid + ')');
});
}
});
});
};