Cross board post move bugfixes/changes

Make rebuilds work for both baords
merge-requests/341/head
Thomas Lynch 1 year ago
parent 344ed5f662
commit 516884cf3e
  1. 18
      db/posts.js
  2. 13
      models/forms/actionhandler.js
  3. 2
      models/forms/moveposts.js

@ -836,7 +836,6 @@ module.exports = {
'locked': '',
'bumplocked': '',
'cyclic': '',
'salt': ''
}
}
}
@ -851,20 +850,19 @@ module.exports = {
'update': {
'$set': {
'thread': null,
//TODO: set these values properly
'replyposts': 0,
'replyfiles': 0,
'sticky': 0,
'locked': 0,
'bumplocked': 0,
'cyclic': 0,
'salt': '',
'replyposts': postMongoIds.length-1,
'replyfiles': 0, //TODO
'sticky': 0, //TODO (tbh we might just wanna set this to 0)
'locked': 0, //TODO
'bumplocked': 0, //TODO
'cyclic': 0, //TOOD
// 'salt': '',
}
}
}
});
}
// console.log(JSON.stringify(bulkWrites, null, 4))
// console.log(JSON.stringify(bulkWrites, null, 4));
const movedPosts = await db.bulkWrite(bulkWrites).then(result => result.modifiedCount);
return { movedPosts, destinationThreadId: newDestinationThreadId };
},

@ -526,6 +526,19 @@ module.exports = async (req, res, next) => {
'endpage': numPagesAfterActions,
}
});
if (res.locals.destinationBoard && res.locals.destinationBoard._id !== req.params.board) {
//cross board move happened, rebuild the other board also
const crossBoardMoveName = res.locals.destinationBoard._id;
const crossBoardMovePages = Math.ceil((await Posts.getPages(crossBoardMoveName)) / 10);
buildQueue.push({
'task': 'buildBoardMultiple',
'options': {
'board': res.locals.destinationBoard,
'startpage': 1,
'endpage': numPagesAfterActions,
}
});
}
} else {

@ -12,7 +12,7 @@ module.exports = async (req, res) => {
const { threads, postIds, postMongoIds } = res.locals.posts
.sort((a, b) => {
return b.date - a.date; //could do postId, doesn't really matter.
return a.date - b.date; //could do postId, doesn't really matter.
}).reduce((acc, p) => {
acc.postIds.push(p.postId);
acc.postMongoIds.push(p._id);

Loading…
Cancel
Save