thread delete restore fix

v1.18.x
Baris Soner Usakli 11 years ago
parent fd88aff195
commit e2fb617cc0

@ -152,7 +152,7 @@ var winston = require('winston'),
// Delete the thread if it is the last undeleted post // Delete the thread if it is the last undeleted post
threadTools.getLatestUndeletedPid(postData.tid, function(err, pid) { threadTools.getLatestUndeletedPid(postData.tid, function(err, pid) {
if (err && err.message === 'no-undeleted-pids-found') { if (err && err.message === 'no-undeleted-pids-found') {
threadTools.delete(postData.tid, function(err) { threadTools.delete(postData.tid, uid, function(err) {
if (err) { if (err) {
winston.error('Could not delete topic (tid: ' + postData.tid + ')', err.stack); winston.error('Could not delete topic (tid: ' + postData.tid + ')', err.stack);
} }

@ -91,7 +91,7 @@ var winston = require('winston'),
} }
} }
ThreadTools.delete = function(tid, callback) { ThreadTools.delete = function(tid, uid, callback) {
topics.delete(tid); topics.delete(tid);
db.decrObjectField('global', 'topicCount'); db.decrObjectField('global', 'topicCount');
@ -112,7 +112,7 @@ var winston = require('winston'),
} }
} }
ThreadTools.restore = function(tid, socket, callback) { ThreadTools.restore = function(tid, uid, callback) {
topics.restore(tid); topics.restore(tid);
db.incrObjectField('global', 'topicCount'); db.incrObjectField('global', 'topicCount');
ThreadTools.unlock(tid); ThreadTools.unlock(tid);

@ -562,9 +562,10 @@ websockets.init = function(io) {
socket.on('api:topic.delete', function(data) { socket.on('api:topic.delete', function(data) {
threadTools.privileges(data.tid, uid, function(err, privileges) { threadTools.privileges(data.tid, uid, function(err, privileges) {
if (!err && privileges.editable) { if (!err && privileges.editable) {
threadTools.delete(data.tid, function(err) { threadTools.delete(data.tid, uid, function(err) {
if (!err) { if (!err) {
emitTopicPostStats(); emitTopicPostStats();
events.logTopicDelete(uid, data.tid);
socket.emit('api:topic.delete', { socket.emit('api:topic.delete', {
status: 'ok', status: 'ok',
tid: data.tid tid: data.tid
@ -578,7 +579,7 @@ websockets.init = function(io) {
socket.on('api:topic.restore', function(data) { socket.on('api:topic.restore', function(data) {
threadTools.privileges(data.tid, uid, function(err, privileges) { threadTools.privileges(data.tid, uid, function(err, privileges) {
if (!err && privileges.editable) { if (!err && privileges.editable) {
threadTools.restore(data.tid, socket, function(err) { threadTools.restore(data.tid, uid, function(err) {
emitTopicPostStats(); emitTopicPostStats();
socket.emit('api:topic.restore', { socket.emit('api:topic.restore', {

Loading…
Cancel
Save