first pass for #1518

this only handles postTools privileges, topic and category will follow
This commit is contained in:
barisusakli
2014-05-14 17:53:23 -04:00
parent ec5cdd178a
commit 4234057821
8 changed files with 220 additions and 67 deletions

View File

@@ -5,6 +5,7 @@ var async = require('async'),
db = require('../database'),
posts = require('../posts'),
privileges = require('../privileges'),
meta = require('../meta'),
topics = require('../topics'),
favourites = require('../favourites'),
@@ -17,7 +18,6 @@ var async = require('async'),
SocketPosts = {};
SocketPosts.reply = function(socket, data, callback) {
if (!socket.uid && !parseInt(meta.config.allowGuestPosting, 10)) {
@@ -127,10 +127,10 @@ function sendNotificationToPostOwner(data, uid, notification) {
SocketPosts.getRawPost = function(socket, pid, callback) {
async.waterfall([
function(next) {
postTools.privileges(pid, socket.uid, next);
privileges.posts.canRead(pid, socket.uid, next);
},
function(privileges, next) {
if (!privileges || !privileges.meta.read) {
function(canRead, next) {
if (!canRead) {
return next(new Error('[[error:no-privileges]]'));
}
posts.getPostFields(pid, ['content', 'deleted'], next);
@@ -205,7 +205,7 @@ function deleteOrRestore(command, socket, data, callback) {
}
SocketPosts.getPrivileges = function(socket, pid, callback) {
postTools.privileges(pid, socket.uid, function(err, privileges) {
privileges.posts.get(pid, socket.uid, function(err, privileges) {
if(err) {
return callback(err);
}