|
|
@ -168,22 +168,40 @@ function favouriteCommand(socket, command, eventName, notification, data, callba
|
|
|
|
return callback(new Error('[[error:post-deleted]]'));
|
|
|
|
return callback(new Error('[[error:post-deleted]]'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
favourites[command](data.pid, socket.uid, function(err, result) {
|
|
|
|
/*
|
|
|
|
|
|
|
|
hooks:
|
|
|
|
|
|
|
|
filter.post.upvote
|
|
|
|
|
|
|
|
filter.post.downvote
|
|
|
|
|
|
|
|
filter.post.unvote
|
|
|
|
|
|
|
|
filter.post.favourite
|
|
|
|
|
|
|
|
filter.post.unfavourite
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
plugins.fireHook('filter:post.' + command, data, function(err, filteredData) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
return callback(err);
|
|
|
|
return callback(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
socket.emit('posts.' + command, result);
|
|
|
|
executeFavouriteCommand(socket, command, eventName, notification, filteredData, callback);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (result && eventName) {
|
|
|
|
function executeFavouriteCommand(socket, command, eventName, notification, data, callback) {
|
|
|
|
websockets.in(data.room_id).emit('event:' + eventName, result);
|
|
|
|
favourites[command](data.pid, socket.uid, function(err, result) {
|
|
|
|
}
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return callback(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (notification) {
|
|
|
|
socket.emit('posts.' + command, result);
|
|
|
|
SocketPosts.sendNotificationToPostOwner(data.pid, socket.uid, notification);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (result && eventName) {
|
|
|
|
callback();
|
|
|
|
websockets.in(data.room_id).emit('event:' + eventName, result);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (notification) {
|
|
|
|
|
|
|
|
SocketPosts.sendNotificationToPostOwner(data.pid, socket.uid, notification);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|