Edit history is now a category-level privilege

Closes #6425
This commit is contained in:
Julian Lam
2018-06-07 12:23:08 -04:00
parent b2d7455f72
commit 99dc3feeb2
8 changed files with 44 additions and 5 deletions

View File

@@ -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);
});
};
};