mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-17 11:11:04 +01:00
modifyCategory is no longer async
This commit is contained in:
@@ -5,13 +5,17 @@ var validator = require('validator');
|
|||||||
var winston = require('winston');
|
var winston = require('winston');
|
||||||
|
|
||||||
var db = require('../database');
|
var db = require('../database');
|
||||||
var plugins = require('../plugins');
|
|
||||||
|
|
||||||
module.exports = function(Categories) {
|
module.exports = function(Categories) {
|
||||||
|
|
||||||
Categories.getCategoryData = function(cid, callback) {
|
Categories.getCategoryData = function(cid, callback) {
|
||||||
Categories.getCategoriesData([cid], function(err, categories) {
|
db.getObject('category:' + cid, function(err, category) {
|
||||||
callback(err, categories ? categories[0] : null);
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
modifyCategory(category);
|
||||||
|
callback(null, category);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -28,13 +32,14 @@ module.exports = function(Categories) {
|
|||||||
return callback(err, []);
|
return callback(err, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
async.map(categories, modifyCategory, callback);
|
categories.forEach(modifyCategory);
|
||||||
|
callback(null, categories);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function modifyCategory(category, callback) {
|
function modifyCategory(category) {
|
||||||
if (!category) {
|
if (!category) {
|
||||||
return callback(null, null);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
category.name = validator.escape(category.name);
|
category.name = validator.escape(category.name);
|
||||||
@@ -56,8 +61,6 @@ module.exports = function(Categories) {
|
|||||||
category.description = validator.escape(category.description);
|
category.description = validator.escape(category.description);
|
||||||
category.descriptionParsed = category.descriptionParsed || category.description;
|
category.descriptionParsed = category.descriptionParsed || category.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, category);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Categories.getCategoryField = function(cid, field, callback) {
|
Categories.getCategoryField = function(cid, field, callback) {
|
||||||
@@ -77,7 +80,9 @@ module.exports = function(Categories) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
async.map(categories, modifyCategory, callback);
|
|
||||||
|
categories.forEach(modifyCategory);
|
||||||
|
callback(null, categories);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user