mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
@@ -2,10 +2,16 @@
|
||||
|
||||
var async = require('async');
|
||||
var posts = require('../../posts');
|
||||
var privileges = require('../../privileges');
|
||||
|
||||
module.exports = function (SocketPosts) {
|
||||
SocketPosts.getDiffs = function (socket, data, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
privileges.posts.can('posts:history', data.pid, socket.uid, function (err, allowed) {
|
||||
next(err || allowed ? null : new Error('[[error:no-privileges]]'));
|
||||
});
|
||||
},
|
||||
function (next) {
|
||||
posts.diffs.list(data.pid, next);
|
||||
},
|
||||
@@ -17,6 +23,12 @@ module.exports = function (SocketPosts) {
|
||||
};
|
||||
|
||||
SocketPosts.showPostAt = function (socket, data, callback) {
|
||||
posts.diffs.load(data.pid, data.since, socket.uid, callback);
|
||||
privileges.posts.can('posts:history', data.pid, socket.uid, function (err, allowed) {
|
||||
if (err || !allowed) {
|
||||
return callback(err || new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
|
||||
posts.diffs.load(data.pid, data.since, socket.uid, callback);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user