|
|
|
@ -57,23 +57,23 @@ module.exports = function(Topics) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Topics.updateTags = function(tid, tags) {
|
|
|
|
|
async.parallel({
|
|
|
|
|
timestamp: function(next) {
|
|
|
|
|
Topics.getTopicField(tid, 'timestamp', next);
|
|
|
|
|
},
|
|
|
|
|
currentTags: function(next) {
|
|
|
|
|
Topics.getTopicTags(tid, next);
|
|
|
|
|
}
|
|
|
|
|
}, function(err, results) {
|
|
|
|
|
removeTopicTags(tid, results.currentTags, function(err) {
|
|
|
|
|
Topics.getTopicField(tid, 'timestamp', function(err, timestamp) {
|
|
|
|
|
if (!err) {
|
|
|
|
|
Topics.deleteTopicTags(tid, function(err) {
|
|
|
|
|
if (!err) {
|
|
|
|
|
Topics.createTags(tags, tid, results.timestamp);
|
|
|
|
|
Topics.createTags(tags, tid, timestamp);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function removeTopicTags(tid, tags, callback) {
|
|
|
|
|
Topics.deleteTopicTags = function(tid, callback) {
|
|
|
|
|
Topics.getTopicTags(tid, function(err, tags) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async.parallel([
|
|
|
|
|
function(next) {
|
|
|
|
|
db.delete('topic:' + tid + ':tags', next);
|
|
|
|
@ -84,7 +84,8 @@ module.exports = function(Topics) {
|
|
|
|
|
}, next);
|
|
|
|
|
}
|
|
|
|
|
], callback);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Topics.searchTags = function(query, callback) {
|
|
|
|
|
if (!query || query.length === 0) {
|
|
|
|
|