Fix bug (#19757)
This commit is contained in:
parent
09b76295f1
commit
57e816311b
@ -155,31 +155,26 @@ func toggleUserAssignee(e db.Engine, issue *Issue, assigneeID int64) (removed bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if the submitted user is already assigned, if yes delete him otherwise add him
|
// Check if the submitted user is already assigned, if yes delete him otherwise add him
|
||||||
var i int
|
found := false
|
||||||
for i = 0; i < len(issue.Assignees); i++ {
|
i := 0
|
||||||
|
for ; i < len(issue.Assignees); i++ {
|
||||||
if issue.Assignees[i].ID == assigneeID {
|
if issue.Assignees[i].ID == assigneeID {
|
||||||
|
found = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assigneeIn := IssueAssignees{AssigneeID: assigneeID, IssueID: issue.ID}
|
assigneeIn := IssueAssignees{AssigneeID: assigneeID, IssueID: issue.ID}
|
||||||
|
|
||||||
toBeDeleted := i < len(issue.Assignees)
|
if found {
|
||||||
if toBeDeleted {
|
issue.Assignees = append(issue.Assignees[:i], issue.Assignees[i+1:]...)
|
||||||
issue.Assignees = append(issue.Assignees[:i], issue.Assignees[i:]...)
|
|
||||||
_, err = e.Delete(assigneeIn)
|
_, err = e.Delete(assigneeIn)
|
||||||
if err != nil {
|
|
||||||
return toBeDeleted, err
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
issue.Assignees = append(issue.Assignees, assignee)
|
issue.Assignees = append(issue.Assignees, assignee)
|
||||||
_, err = e.Insert(assigneeIn)
|
_, err = e.Insert(assigneeIn)
|
||||||
if err != nil {
|
|
||||||
return toBeDeleted, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return toBeDeleted, nil
|
return found, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// MakeIDsFromAPIAssigneesToAdd returns an array with all assignee IDs
|
// MakeIDsFromAPIAssigneesToAdd returns an array with all assignee IDs
|
||||||
|
@ -16,9 +16,10 @@ import (
|
|||||||
// DeleteNotPassedAssignee deletes all assignees who aren't passed via the "assignees" array
|
// DeleteNotPassedAssignee deletes all assignees who aren't passed via the "assignees" array
|
||||||
func DeleteNotPassedAssignee(issue *models.Issue, doer *user_model.User, assignees []*user_model.User) (err error) {
|
func DeleteNotPassedAssignee(issue *models.Issue, doer *user_model.User, assignees []*user_model.User) (err error) {
|
||||||
var found bool
|
var found bool
|
||||||
|
oriAssignes := make([]*user_model.User, len(issue.Assignees))
|
||||||
|
_ = copy(oriAssignes, issue.Assignees)
|
||||||
|
|
||||||
for _, assignee := range issue.Assignees {
|
for _, assignee := range oriAssignes {
|
||||||
|
|
||||||
found = false
|
found = false
|
||||||
for _, alreadyAssignee := range assignees {
|
for _, alreadyAssignee := range assignees {
|
||||||
if assignee.ID == alreadyAssignee.ID {
|
if assignee.ID == alreadyAssignee.ID {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user