mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-01 10:01:12 +01:00
add back thread tools filter
This commit is contained in:
@@ -4,6 +4,7 @@ var async = require('async');
|
|||||||
var topics = require('../../topics');
|
var topics = require('../../topics');
|
||||||
var events = require('../../events');
|
var events = require('../../events');
|
||||||
var privileges = require('../../privileges');
|
var privileges = require('../../privileges');
|
||||||
|
var plugins = require('../../plugins');
|
||||||
var socketHelpers = require('../helpers');
|
var socketHelpers = require('../helpers');
|
||||||
|
|
||||||
module.exports = function(SocketTopics) {
|
module.exports = function(SocketTopics) {
|
||||||
@@ -13,28 +14,33 @@ module.exports = function(SocketTopics) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return callback(new Error('[[error:invalid-data]]'))
|
return callback(new Error('[[error:invalid-data]]'));
|
||||||
}
|
}
|
||||||
|
var topic;
|
||||||
async.parallel({
|
async.waterfall([
|
||||||
topic: function(next) {
|
function (next) {
|
||||||
topics.getTopicFields(data.tid, ['deleted', 'locked', 'pinned'], next);
|
async.parallel({
|
||||||
|
topic: function(next) {
|
||||||
|
topics.getTopicData(data.tid, next);
|
||||||
|
},
|
||||||
|
privileges: function(next) {
|
||||||
|
privileges.topics.get(data.tid, socket.uid, next);
|
||||||
|
}
|
||||||
|
}, next);
|
||||||
},
|
},
|
||||||
privileges: function(next) {
|
function (results, next) {
|
||||||
privileges.topics.get(data.tid, socket.uid, next);
|
topic = results.topic;
|
||||||
|
topic.privileges = results.privileges;
|
||||||
|
plugins.fireHook('filter:topic.thread_tools', {topic: results.topic, uid: socket.uid, tools: []}, next);
|
||||||
|
},
|
||||||
|
function (data, next) {
|
||||||
|
topic.deleted = parseInt(topic.deleted, 10) === 1;
|
||||||
|
topic.locked = parseInt(topic.locked, 10) === 1;
|
||||||
|
topic.pinned = parseInt(topic.pinned, 10) === 1;
|
||||||
|
topic.thread_tools = data.tools;
|
||||||
|
next(null, topic);
|
||||||
}
|
}
|
||||||
}, function(err, results) {
|
], callback);
|
||||||
if (err) {
|
|
||||||
return callback(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
results.topic.deleted = parseInt(results.topic.deleted, 10) === 1;
|
|
||||||
results.topic.locked = parseInt(results.topic.locked, 10) === 1;
|
|
||||||
results.topic.pinned = parseInt(results.topic.pinned, 10) === 1;
|
|
||||||
results.topic.privileges = results.privileges;
|
|
||||||
|
|
||||||
callback(null, results.topic);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketTopics.delete = function(socket, data, callback) {
|
SocketTopics.delete = function(socket, data, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user