fix(teams): complete task sorting

This commit is contained in:
SabreCat
2022-06-24 16:43:41 -05:00
parent 9142588ba7
commit 712b85ce84
2 changed files with 9 additions and 4 deletions

View File

@@ -819,7 +819,7 @@ api.moveTask = {
if (task.type === 'todo' && task.completed) throw new BadRequest(res.t('cantMoveCompletedTodo')); if (task.type === 'todo' && task.completed) throw new BadRequest(res.t('cantMoveCompletedTodo'));
const owner = group || challenge || user; const owner = challenge || user;
// In memory updates // In memory updates
const order = owner.tasksOrder[`${task.type}s`]; const order = owner.tasksOrder[`${task.type}s`];
@@ -846,7 +846,7 @@ api.moveTask = {
// it cannot be updated in the pre update hook // it cannot be updated in the pre update hook
// See https://github.com/HabitRPG/habitica/pull/9321#issuecomment-354187666 for more info // See https://github.com/HabitRPG/habitica/pull/9321#issuecomment-354187666 for more info
// Only users have a version. // Only users have a version.
if (!group && !challenge) { if (!challenge) {
owner._v += 1; owner._v += 1;
} }

View File

@@ -326,8 +326,13 @@ function verifyTaskModification (task, user, group, challenge, res) {
if (!task) { if (!task) {
throw new NotFound(res.t('messageTaskNotFound')); throw new NotFound(res.t('messageTaskNotFound'));
} else if (task.group.id && !task.userId) { } else if (task.group.id && !task.userId) {
if (!group) throw new NotFound(res.t('groupNotFound')); if (!group || user.guilds.concat(user.party._id).indexOf(group._id) === -1) {
if (canNotEditTasks(group, user)) throw new NotAuthorized(res.t('onlyGroupLeaderCanEditTasks')); throw new NotFound(res.t('groupNotFound'));
}
if (task.group.assignedUsers.length !== 0
&& task.group.assignedUsers.indexOf(user._id) === -1) {
throw new BadRequest('Use /group/:groupId/tasks/:taskId/move/to/:position route');
}
// If the task belongs to a challenge make sure the user has rights // If the task belongs to a challenge make sure the user has rights
} else if (task.challenge.id && !task.userId) { } else if (task.challenge.id && !task.userId) {