mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 00:15:46 +01:00
deleting a user will delete topic tags too
This commit is contained in:
@@ -57,34 +57,35 @@ module.exports = function(Topics) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Topics.updateTags = function(tid, tags) {
|
Topics.updateTags = function(tid, tags) {
|
||||||
async.parallel({
|
Topics.getTopicField(tid, 'timestamp', function(err, timestamp) {
|
||||||
timestamp: function(next) {
|
if (!err) {
|
||||||
Topics.getTopicField(tid, 'timestamp', next);
|
Topics.deleteTopicTags(tid, function(err) {
|
||||||
},
|
if (!err) {
|
||||||
currentTags: function(next) {
|
Topics.createTags(tags, tid, timestamp);
|
||||||
Topics.getTopicTags(tid, next);
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, function(err, results) {
|
|
||||||
removeTopicTags(tid, results.currentTags, function(err) {
|
|
||||||
if (!err) {
|
|
||||||
Topics.createTags(tags, tid, results.timestamp);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function removeTopicTags(tid, tags, callback) {
|
Topics.deleteTopicTags = function(tid, callback) {
|
||||||
async.parallel([
|
Topics.getTopicTags(tid, function(err, tags) {
|
||||||
function(next) {
|
if (err) {
|
||||||
db.delete('topic:' + tid + ':tags', next);
|
return callback(err);
|
||||||
},
|
|
||||||
function(next) {
|
|
||||||
async.each(tags, function(tag, next) {
|
|
||||||
db.sortedSetRemove('tag:' + tag + ':topics', tid, next);
|
|
||||||
}, next);
|
|
||||||
}
|
}
|
||||||
], callback);
|
|
||||||
}
|
async.parallel([
|
||||||
|
function(next) {
|
||||||
|
db.delete('topic:' + tid + ':tags', next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
async.each(tags, function(tag, next) {
|
||||||
|
db.sortedSetRemove('tag:' + tag + ':topics', tid, next);
|
||||||
|
}, next);
|
||||||
|
}
|
||||||
|
], callback);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
Topics.searchTags = function(query, callback) {
|
Topics.searchTags = function(query, callback) {
|
||||||
if (!query || query.length === 0) {
|
if (!query || query.length === 0) {
|
||||||
|
|||||||
@@ -153,7 +153,6 @@ module.exports = function(User) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function deleteTopic(tid, callback) {
|
function deleteTopic(tid, callback) {
|
||||||
|
|
||||||
async.parallel([
|
async.parallel([
|
||||||
function(next) {
|
function(next) {
|
||||||
db.delete('tid:' + tid + ':followers', next);
|
db.delete('tid:' + tid + ':followers', next);
|
||||||
@@ -175,6 +174,9 @@ module.exports = function(User) {
|
|||||||
},
|
},
|
||||||
function(next) {
|
function(next) {
|
||||||
deleteTopicFromCategory(tid, next);
|
deleteTopicFromCategory(tid, next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
topics.deleteTopicTags(tid, next);
|
||||||
}
|
}
|
||||||
], function(err) {
|
], function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user