fix(tasks): no really, address not-found error

This commit is contained in:
SabreCat
2022-08-23 10:48:21 -05:00
parent 395b8db932
commit 971891dd6b
@@ -356,11 +356,13 @@ api.taskNeedsWork = {
if (['daily', 'todo'].indexOf(task.type) === -1) {
throw new BadRequest('Cannot roll back use of Habits or Rewards.');
}
if (!task.group.assignedUsersDetail) task.group.assignedUsersDetail = {};
if (
(task.group.completedBy.userId && task.group.completedBy.userId !== assignedUserId)
|| !(task.group.assignedUsersDetail[assignedUserId]
&& task.group.assignedUsersDetail[assignedUserId].completed)) {
if (task.group.completedBy.userId) {
if (task.group.completedBy.userId !== assignedUserId) {
throw new BadRequest('Task not completed by this user.');
}
} else if (!task.group.assignedUsersDetail || !task.group.assignedUsersDetail[assignedUserId]
|| !task.group.assignedUsersDetail[assignedUserId].completed) {
throw new BadRequest('Task not completed by this user.');
}