Add edit, delete, and topics:delete permissions for users acting on their own posts

This commit is contained in:
Ben Lubar
2016-08-06 20:28:55 -05:00
parent b0c55c86ed
commit 26df552d55
13 changed files with 213 additions and 24 deletions

View File

@@ -28,6 +28,12 @@ module.exports = function(SocketPosts) {
isAdminOrMod: function(next) {
privileges.categories.isAdminOrMod(data.cid, socket.uid, next);
},
canEdit: function(next) {
privileges.posts.canEdit(data.pid, socket.uid, next);
},
canDelete: function(next) {
privileges.posts.canDelete(data.pid, socket.uid, next);
},
favourited: function(next) {
favourites.getFavouritesByPostIDs([data.pid], socket.uid, next);
},
@@ -45,7 +51,9 @@ module.exports = function(SocketPosts) {
results.posts.deleted = parseInt(results.posts.deleted, 10) === 1;
results.posts.favourited = results.favourited[0];
results.posts.selfPost = socket.uid && socket.uid === parseInt(results.posts.uid, 10);
results.posts.display_moderator_tools = results.isAdminOrMod || results.posts.selfPost;
results.posts.display_edit_tools = results.canEdit;
results.posts.display_delete_tools = results.canDelete;
results.posts.display_moderator_tools = results.posts.display_edit_tools || results.posts.display_delete_tools;
results.posts.display_move_tools = results.isAdminOrMod;
callback(null, results);
});
@@ -165,4 +173,4 @@ module.exports = function(SocketPosts) {
}, callback);
}
};
};