v1.18.x
Baris Soner Usakli 11 years ago
parent 042174290f
commit b717c74a81

@ -207,17 +207,21 @@ var winston = require('winston'),
});
});
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);
threadTools.restore(postData.tid, uid, function(err) {
if(err) {
winston.err(err);
}
});
}
});
Feed.updateTopic(postData.tid);
Feed.updateRecent();
db.searchIndex('post', postData.content, pid);
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) {

Loading…
Cancel
Save