add new hook to add more fields to csv download

v1.18.x
barisusakli 8 years ago
parent 8c7de0f239
commit b1773ad51d

@ -30,16 +30,19 @@ module.exports = function (User) {
User.getUsersCSV = function (callback) { User.getUsersCSV = function (callback) {
winston.info('[user/getUsersCSV] Compiling User CSV data'); winston.info('[user/getUsersCSV] Compiling User CSV data');
var csvContent = ''; var csvContent = '';
var uids;
async.waterfall([ async.waterfall([
function (next) { function (next) {
db.getSortedSetRangeWithScores('username:uid', 0, -1, next); db.getSortedSetRangeWithScores('username:uid', 0, -1, next);
}, },
function (users, next) { function (users, next) {
var uids = users.map(function (user) { uids = users.map(function (user) {
return user.score; return user.score;
}); });
User.getUsersFields(uids, ['uid', 'email', 'username'], next); plugins.fireHook('filter:user.csvFields', {fields: ['uid', 'email', 'username']}, next);
},
function (data, next) {
User.getUsersFields(uids, data.fields, next);
}, },
function (usersData, next) { function (usersData, next) {
usersData.forEach(function (user) { usersData.forEach(function (user) {

Loading…
Cancel
Save