v3: check that tasks are deleted when the user deletes the acocunt and misc fixes

This commit is contained in:
Matteo Pagliazzi
2016-04-04 17:16:36 +02:00
parent 1620614b3b
commit 68ff26e6d6
4 changed files with 30 additions and 5 deletions
+2 -3
View File
@@ -399,6 +399,7 @@ api.scoreTask = {
if (direction === 'up') user.fns.randomDrop({task, delta}, req);
// If a todo was completed or uncompleted move it in or out of the user.tasksOrder.todos list
// TODO move to common code?
if (task.type === 'todo') {
if (!wasCompleted && task.completed) {
removeFromArray(user.tasksOrder.todos, task._id);
@@ -406,9 +407,7 @@ api.scoreTask = {
let hasTask = removeFromArray(user.tasksOrder.todos, task._id);
if (!hasTask) {
user.tasksOrder.todos.push(task._id); // TODO push at the top?
} else { // If for some reason it hadn't been removed TODO ok?
user.tasksOrder.push(task._id);
}
} // If for some reason it hadn't been removed previously don't do anything TODO ok?
}
}
+4
View File
@@ -219,6 +219,10 @@ api.deleteUser = {
await Q.all(groupLeavePromises);
await Tasks.Task.remove({
userId: user._id,
}).exec();
await user.remove();
res.respond(200, {});