1
0

fix: make sure a user can only be assigned once to a task

See https://community.vikunja.io/t/task-can-be-assigned-twice-or-more-to-the-same-user/883
This commit is contained in:
kolaente
2022-10-06 18:10:36 +02:00
parent 12e0e12bae
commit 008908eb49
3 changed files with 42 additions and 0 deletions

View File

@ -221,6 +221,19 @@ func (t *Task) addNewAssigneeByID(s *xorm.Session, newAssigneeID int64, list *Li
return ErrUserDoesNotHaveAccessToList{list.ID, newAssigneeID}
}
exist, err := s.
Where("task_id = ? AND user_id = ?", t.ID, newAssigneeID).
Exist(&TaskAssginee{})
if err != nil {
return err
}
if exist {
return &ErrUserAlreadyAssigned{
UserID: newAssigneeID,
TaskID: t.ID,
}
}
_, err = s.Insert(TaskAssginee{
TaskID: t.ID,
UserID: newAssigneeID,