Skip to content

Node.js based forum software built for the modern web

thread delete restore fix

Baris Soner Usaklie2fb617cc05c
diff --git a/src/postTools.js b/src/postTools.js
index 5af411e55e..37d1ac0a53 100644
--- a/src/postTools.js
+++ b/src/postTools.js
@@ -152,7 +152,7 @@ var winston = require('winston'),
// Delete the thread if it is the last undeleted post
threadTools.getLatestUndeletedPid(postData.tid, function(err, pid) {
if (err && err.message === 'no-undeleted-pids-found') {
- threadTools.delete(postData.tid, function(err) {
+ threadTools.delete(postData.tid, uid, function(err) {
if (err) {
winston.error('Could not delete topic (tid: ' + postData.tid + ')', err.stack);
}
diff --git a/src/threadTools.js b/src/threadTools.js
index 859d6faac4..b69c42fa7c 100644
--- a/src/threadTools.js
+++ b/src/threadTools.js
@@ -91,7 +91,7 @@ var winston = require('winston'),
}
}
- ThreadTools.delete = function(tid, callback) {
+ ThreadTools.delete = function(tid, uid, callback) {
topics.delete(tid);
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);
db.incrObjectField('global', 'topicCount');
ThreadTools.unlock(tid);
diff --git a/src/websockets.js b/src/websockets.js
index b435d4b6ec..9682e6cfef 100644
--- a/src/websockets.js
+++ b/src/websockets.js
@@ -562,9 +562,10 @@ websockets.init = function(io) {
socket.on('api:topic.delete', function(data) {
threadTools.privileges(data.tid, uid, function(err, privileges) {
if (!err && privileges.editable) {
- threadTools.delete(data.tid, function(err) {
+ threadTools.delete(data.tid, uid, function(err) {
if (!err) {
emitTopicPostStats();
+ events.logTopicDelete(uid, data.tid);
socket.emit('api:topic.delete', {
status: 'ok',
tid: data.tid
@@ -578,7 +579,7 @@ websockets.init = function(io) {
socket.on('api:topic.restore', function(data) {
threadTools.privileges(data.tid, uid, function(err, privileges) {
if (!err && privileges.editable) {
- threadTools.restore(data.tid, socket, function(err) {
+ threadTools.restore(data.tid, uid, function(err) {
emitTopicPostStats();
socket.emit('api:topic.restore', {