mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-08 00:22:51 +01:00
fixes forking
if there are no tags just return
This commit is contained in:
@@ -9,25 +9,27 @@ var async = require('async'),
|
||||
module.exports = function(Topics) {
|
||||
|
||||
Topics.createTags = function(tags, tid, timestamp, callback) {
|
||||
if(Array.isArray(tags)) {
|
||||
tags = tags.slice(0, meta.config.tagsPerTopic || 5);
|
||||
|
||||
async.each(tags, function(tag, next) {
|
||||
tag = cleanUpTag(tag);
|
||||
|
||||
if (tag.length < (meta.config.minimumTagLength || 3)) {
|
||||
return next();
|
||||
}
|
||||
db.setAdd('topic:' + tid + ':tags', tag);
|
||||
|
||||
db.sortedSetAdd('tag:' + tag + ':topics', timestamp, tid, function(err) {
|
||||
if (!err) {
|
||||
updateTagCount(tag);
|
||||
}
|
||||
next(err);
|
||||
});
|
||||
}, callback);
|
||||
if (!Array.isArray(tags) || !tags.length) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
tags = tags.slice(0, meta.config.tagsPerTopic || 5);
|
||||
|
||||
async.each(tags, function(tag, next) {
|
||||
tag = cleanUpTag(tag);
|
||||
|
||||
if (tag.length < (meta.config.minimumTagLength || 3)) {
|
||||
return next();
|
||||
}
|
||||
db.setAdd('topic:' + tid + ':tags', tag);
|
||||
|
||||
db.sortedSetAdd('tag:' + tag + ':topics', timestamp, tid, function(err) {
|
||||
if (!err) {
|
||||
updateTagCount(tag);
|
||||
}
|
||||
next(err);
|
||||
});
|
||||
}, callback);
|
||||
};
|
||||
|
||||
function cleanUpTag(tag) {
|
||||
|
||||
Reference in New Issue
Block a user