mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 11:27:01 +02:00
Merge remote-tracking branch 'origin/master' into user-icons
Conflicts: src/controllers/index.js src/topics/tags.js
This commit is contained in:
@@ -43,7 +43,7 @@
|
||||
"nodebb-plugin-composer-default": "1.0.20",
|
||||
"nodebb-plugin-dbsearch": "0.2.17",
|
||||
"nodebb-plugin-emoji-extended": "0.4.15",
|
||||
"nodebb-plugin-markdown": "4.0.6",
|
||||
"nodebb-plugin-markdown": "4.0.7",
|
||||
"nodebb-plugin-mentions": "1.0.8",
|
||||
"nodebb-plugin-soundpack-default": "0.1.4",
|
||||
"nodebb-plugin-spam-be-gone": "0.4.2",
|
||||
|
||||
@@ -5,13 +5,17 @@ var validator = require('validator');
|
||||
var winston = require('winston');
|
||||
|
||||
var db = require('../database');
|
||||
var plugins = require('../plugins');
|
||||
|
||||
module.exports = function(Categories) {
|
||||
|
||||
Categories.getCategoryData = function(cid, callback) {
|
||||
Categories.getCategoriesData([cid], function(err, categories) {
|
||||
callback(err, categories ? categories[0] : null);
|
||||
db.getObject('category:' + cid, function(err, category) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
modifyCategory(category);
|
||||
callback(null, category);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -28,13 +32,14 @@ module.exports = function(Categories) {
|
||||
return callback(err, []);
|
||||
}
|
||||
|
||||
async.map(categories, modifyCategory, callback);
|
||||
categories.forEach(modifyCategory);
|
||||
callback(null, categories);
|
||||
});
|
||||
};
|
||||
|
||||
function modifyCategory(category, callback) {
|
||||
function modifyCategory(category) {
|
||||
if (!category) {
|
||||
return callback(null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
category.name = validator.escape(category.name);
|
||||
@@ -56,8 +61,6 @@ module.exports = function(Categories) {
|
||||
category.description = validator.escape(category.description);
|
||||
category.descriptionParsed = category.descriptionParsed || category.description;
|
||||
}
|
||||
|
||||
callback(null, category);
|
||||
}
|
||||
|
||||
Categories.getCategoryField = function(cid, field, callback) {
|
||||
@@ -77,7 +80,9 @@ module.exports = function(Categories) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
async.map(categories, modifyCategory, callback);
|
||||
|
||||
categories.forEach(modifyCategory);
|
||||
callback(null, categories);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -72,9 +72,7 @@ topicsController.get = function(req, res, callback) {
|
||||
reverse = false;
|
||||
|
||||
// `sort` qs has priority over user setting
|
||||
if (sort === 'oldest_to_newest') {
|
||||
reverse = false;
|
||||
} else if (sort === 'newest_to_oldest') {
|
||||
if (sort === 'newest_to_oldest') {
|
||||
reverse = true;
|
||||
} else if (sort === 'most_votes') {
|
||||
reverse = true;
|
||||
|
||||
@@ -24,23 +24,23 @@ module.exports = function(Topics) {
|
||||
},
|
||||
function (data, next) {
|
||||
tags = data.tags.slice(0, meta.config.maximumTagsPerTopic || 5);
|
||||
tags = tags.map(Topics.cleanUpTag).filter(function(tag) {
|
||||
return tag && tag.length >= (meta.config.minimumTagLength || 3);
|
||||
});
|
||||
|
||||
async.each(tags, function(tag, next) {
|
||||
tag = Topics.cleanUpTag(tag);
|
||||
if (tag.length < (meta.config.minimumTagLength || 3)) {
|
||||
return next();
|
||||
var keys = tags.map(function(tag) {
|
||||
return 'tag:' + tag + ':topics';
|
||||
});
|
||||
|
||||
async.parallel([
|
||||
async.apply(db.setAdd, 'topic:' + tid + ':tags', tags),
|
||||
async.apply(db.sortedSetsAdd, keys, timestamp, tid)
|
||||
], function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
async.parallel([
|
||||
async.apply(db.setAdd, 'topic:' + tid + ':tags', tag),
|
||||
async.apply(db.sortedSetAdd, 'tag:' + tag + ':topics', timestamp, tid)
|
||||
], function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
updateTagCount(tag, next);
|
||||
});
|
||||
}, next);
|
||||
async.each(tags, updateTagCount, next);
|
||||
});
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
@@ -66,9 +66,10 @@ module.exports = function(Topics) {
|
||||
function updateTagCount(tag, callback) {
|
||||
callback = callback || function() {};
|
||||
Topics.getTagTopicCount(tag, function(err, count) {
|
||||
if (err || !count) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
count = count || 0;
|
||||
|
||||
db.sortedSetAdd('tags:topic:count', count, tag, callback);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user