privileges.posts.get takes an array of pids now

This commit is contained in:
barisusakli
2014-06-28 14:59:01 -04:00
parent 6cd29a31a4
commit d57f183f42
7 changed files with 108 additions and 29 deletions

View File

@@ -226,12 +226,16 @@ SocketPosts.purge = function(socket, data, callback) {
};
SocketPosts.getPrivileges = function(socket, pid, callback) {
privileges.posts.get(pid, socket.uid, function(err, privileges) {
if(err) {
privileges.posts.get([pid], socket.uid, function(err, privileges) {
if (err) {
return callback(err);
}
privileges.pid = parseInt(pid, 10);
callback(null, privileges);
if (!Array.isArray(privileges) || !privileges.length) {
return callback(new Error('[[error:invalid-data]]'));
}
privileges[0].pid = parseInt(pid, 10);
callback(null, privileges[0]);
});
};