WIP(tests): fix various assign requests and needs-work flow

This commit is contained in:
SabreCat
2022-08-22 20:45:22 -05:00
parent 3ab88bbb3f
commit 02c50b6126
9 changed files with 33 additions and 547 deletions

View File

@@ -956,9 +956,14 @@ api.scoreCheckListItem = {
if (validationErrors) throw validationErrors;
const { taskId } = req.params;
const task = await Tasks.Task.findById(taskId);
const task = await Tasks.Task.findByIdOrAlias(taskId, user._id);
if (!task || (!task.id && !task.group.id)) throw new NotFound(res.t('taskNotFound'));
if (!task || (!task.userId && !task.group.id)) throw new NotFound(res.t('messageTaskNotFound'));
if (task.userId && task.userId !== user._id) {
throw new BadRequest('Cannot score task belonging to another user.');
} else if (user.guilds.indexOf(task.group.id) === -1 && user.party._id !== task.group.id) {
throw new BadRequest('Cannot score task belonging to another user.');
}
if (task.type !== 'daily' && task.type !== 'todo') throw new BadRequest(res.t('checklistOnlyDailyTodo'));
const item = _.find(task.checklist, { id: req.params.itemId });

View File

@@ -347,6 +347,7 @@ api.taskNeedsWork = {
User.findById(assignedUserId).exec(),
await Tasks.Task.findOne({
_id: taskId,
'group.assignedUsers': assignedUserId,
}).exec(),
]);