From 06a59bfe03776e40fb012898d3d7d9cd4014ae5c Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Wed, 28 Aug 2024 15:05:34 -0500 Subject: [PATCH] fix(tasks): always prune __v and add id (#15301) Co-authored-by: Sabe Jones --- website/server/libs/tasks/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/website/server/libs/tasks/index.js b/website/server/libs/tasks/index.js index 64cac230f5..4ad1bb71e0 100644 --- a/website/server/libs/tasks/index.js +++ b/website/server/libs/tasks/index.js @@ -252,6 +252,13 @@ async function getTasks (req, res, options = {}) { const tasks = await mQuery.lean().exec(); + // Ensure we always include the "id" variant of "_id", and not the version counter + tasks.forEach(task => { + task.id = task._id; + delete task.__v; + }); + + // Calculate due dates for Dailies if (dueDate) { tasks.forEach(task => { setNextDue(task, user, dueDate); @@ -288,8 +295,6 @@ async function getTasks (req, res, options = {}) { tasks.forEach((task, index) => { const taskId = task._id; - task.id = task._id; - delete task.__v; const i = order[index] === taskId ? index : order.indexOf(taskId); if (i === -1) { unorderedTasks.push(task);