mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-28 09:36:16 +01:00
moved admin.getVoters to posts.getVoters; now getVoters modal can be accessed by moderators as well
This commit is contained in:
@@ -201,10 +201,7 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
|
|||||||
}
|
}
|
||||||
|
|
||||||
function showVotes(pid) {
|
function showVotes(pid) {
|
||||||
if (!app.isAdmin) {
|
socket.emit('posts.getVoters', {pid: pid, cid: ajaxify.variables.get('category_id')}, function(err, data) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
socket.emit('admin.getVoters', pid, function(err, data) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,35 +283,6 @@ SocketAdmin.getMoreFlags = function(socket, after, callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketAdmin.getVoters = function(socket, pid, callback) {
|
|
||||||
async.parallel({
|
|
||||||
upvoteUids: function(next) {
|
|
||||||
db.getSetMembers('pid:' + pid + ':upvote', next);
|
|
||||||
},
|
|
||||||
downvoteUids: function(next) {
|
|
||||||
db.getSetMembers('pid:' + pid + ':downvote', next);
|
|
||||||
}
|
|
||||||
}, function(err, results) {
|
|
||||||
if (err) {
|
|
||||||
return callback(err);
|
|
||||||
}
|
|
||||||
async.parallel({
|
|
||||||
upvoters: function(next) {
|
|
||||||
user.getMultipleUserFields(results.upvoteUids, ['username', 'userslug', 'picture'], next);
|
|
||||||
},
|
|
||||||
upvoteCount: function(next) {
|
|
||||||
next(null, results.upvoteUids.length);
|
|
||||||
},
|
|
||||||
downvoters: function(next) {
|
|
||||||
user.getMultipleUserFields(results.downvoteUids, ['username', 'userslug', 'picture'], next);
|
|
||||||
},
|
|
||||||
downvoteCount: function(next) {
|
|
||||||
next(null, results.downvoteUids.length);
|
|
||||||
}
|
|
||||||
}, callback);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
SocketAdmin.takeHeapSnapshot = function(socket, data, callback) {
|
SocketAdmin.takeHeapSnapshot = function(socket, data, callback) {
|
||||||
require('heapdump').writeSnapshot(callback);
|
require('heapdump').writeSnapshot(callback);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -69,6 +69,55 @@ SocketPosts.reply = function(socket, data, callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SocketPosts.getVoters = function(socket, data, callback) {
|
||||||
|
var pid = data.pid,
|
||||||
|
cid = data.cid,
|
||||||
|
uid = socket.uid;
|
||||||
|
|
||||||
|
async.parallel([
|
||||||
|
function(next) {
|
||||||
|
user.isAdministrator(uid, next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
user.isModerator(uid, cid, next);
|
||||||
|
}
|
||||||
|
], function(err, tests) {
|
||||||
|
if (tests[0] || tests[1]) {
|
||||||
|
getVoters(pid, callback);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
function getVoters(pid, callback) {
|
||||||
|
async.parallel({
|
||||||
|
upvoteUids: function(next) {
|
||||||
|
db.getSetMembers('pid:' + pid + ':upvote', next);
|
||||||
|
},
|
||||||
|
downvoteUids: function(next) {
|
||||||
|
db.getSetMembers('pid:' + pid + ':downvote', next);
|
||||||
|
}
|
||||||
|
}, function(err, results) {
|
||||||
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
async.parallel({
|
||||||
|
upvoters: function(next) {
|
||||||
|
user.getMultipleUserFields(results.upvoteUids, ['username', 'userslug', 'picture'], next);
|
||||||
|
},
|
||||||
|
upvoteCount: function(next) {
|
||||||
|
next(null, results.upvoteUids.length);
|
||||||
|
},
|
||||||
|
downvoters: function(next) {
|
||||||
|
user.getMultipleUserFields(results.downvoteUids, ['username', 'userslug', 'picture'], next);
|
||||||
|
},
|
||||||
|
downvoteCount: function(next) {
|
||||||
|
next(null, results.downvoteUids.length);
|
||||||
|
}
|
||||||
|
}, callback);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
SocketPosts.upvote = function(socket, data, callback) {
|
SocketPosts.upvote = function(socket, data, callback) {
|
||||||
favouriteCommand(socket, 'upvote', 'voted', 'notifications:upvoted_your_post_in', data, callback);
|
favouriteCommand(socket, 'upvote', 'voted', 'notifications:upvoted_your_post_in', data, callback);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user