v1.18.x
psychobunny 9 years ago
commit 8787f04757

@ -7,14 +7,14 @@ var events = require('../../events');
var websockets = require('../index'); var websockets = require('../index');
var socketTopics = require('../topics'); var socketTopics = require('../topics');
var privileges = require('../../privileges'); var privileges = require('../../privileges');
var plugins = require('../../plugins');
var favourites = require('../../favourites'); var favourites = require('../../favourites');
module.exports = function(SocketPosts) { module.exports = function(SocketPosts) {
SocketPosts.loadPostTools = function(socket, data, callback) { SocketPosts.loadPostTools = function(socket, data, callback) {
if (!data) { if (!data) {
return callback(new Error('[[error:invalid-data]]')) return callback(new Error('[[error:invalid-data]]'));
} }
async.parallel({ async.parallel({
@ -26,12 +26,15 @@ module.exports = function(SocketPosts) {
}, },
favourited: function(next) { favourited: function(next) {
favourites.getFavouritesByPostIDs([data.pid], socket.uid, next); favourites.getFavouritesByPostIDs([data.pid], socket.uid, next);
},
tools: function(next) {
plugins.fireHook('filter:post.tools', {pid: data.pid, uid: socket.uid, tools: []}, next);
} }
}, function(err, results) { }, function(err, results) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
results.posts.tools = []; // TODO: add filter for this results.posts.tools = results.tools.tools;
results.posts.deleted = parseInt(results.posts.deleted, 10) === 1; results.posts.deleted = parseInt(results.posts.deleted, 10) === 1;
results.posts.favourited = results.favourited[0]; results.posts.favourited = results.favourited[0];
results.posts.selfPost = socket.uid && socket.uid === parseInt(results.posts.uid, 10); results.posts.selfPost = socket.uid && socket.uid === parseInt(results.posts.uid, 10);

Loading…
Cancel
Save