mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-30 20:30:32 +01:00
when a post is moved update recent topics order
This commit is contained in:
@@ -44,7 +44,7 @@ module.exports = function(Topics) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
|
||||
Topics.create({uid: results.postData.uid, title: title, cid: results.cid}, function(err, tid) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -94,7 +94,7 @@ module.exports = function(Topics) {
|
||||
}
|
||||
|
||||
if (parseInt(post.tid, 10) === parseInt(tid, 10)) {
|
||||
return next(new Error('[[error:cant-move-to-same-topic]]'))
|
||||
return next(new Error('[[error:cant-move-to-same-topic]]'));
|
||||
}
|
||||
|
||||
postData = post;
|
||||
@@ -117,6 +117,12 @@ module.exports = function(Topics) {
|
||||
Topics.addPostToTopic(tid, pid, postData.timestamp, postData.votes, next);
|
||||
}
|
||||
], next);
|
||||
},
|
||||
function(results, next) {
|
||||
async.parallel([
|
||||
async.apply(updateRecentTopic, tid),
|
||||
async.apply(updateRecentTopic, postData.tid)
|
||||
], next);
|
||||
}
|
||||
], function(err) {
|
||||
if (err) {
|
||||
@@ -126,4 +132,23 @@ module.exports = function(Topics) {
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
function updateRecentTopic(tid, callback) {
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
Topics.getLatestUndeletedPid(tid, next);
|
||||
},
|
||||
function(pid, next) {
|
||||
if (!pid) {
|
||||
return callback();
|
||||
}
|
||||
posts.getPostField(pid, 'timestamp', next);
|
||||
},
|
||||
function(timestamp, next) {
|
||||
Topics.updateTimestamp(tid, timestamp, next);
|
||||
}
|
||||
], callback);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user