summaryrefslogtreecommitdiffstats
path: root/models/issue_assignees.go
diff options
context:
space:
mode:
author6543 <24977596+6543@users.noreply.github.com>2019-11-10 09:07:21 +0100
committerLunny Xiao <xiaolunwen@gmail.com>2019-11-10 16:07:21 +0800
commit31416a5f4e70d4972c351cde170b59d13fcbb77f (patch)
tree9ab42512fa2989932b6ef69d91606441bd8f9a7d /models/issue_assignees.go
parentdaab2451676b1a3a5312af0e2a443e6017113702 (diff)
downloadgitea-31416a5f4e70d4972c351cde170b59d13fcbb77f.tar.gz
gitea-31416a5f4e70d4972c351cde170b59d13fcbb77f.zip
Fix API Bug (fail on empty assignees) (#8873)
* keep sure if assigneeIDs == nil -> do nothing * fix #8872 * Revert "keep sure if assigneeIDs == nil -> do nothing" -> go handle it itself preaty well This reverts commit e72d94129c4666d5151f6131cb2f8c1de127d9d0. * clarity comparson Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * simplify * Update models/issue_assignees.go Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * Update issue_assignees.go * simplify more * add --if oneAssignee != ""-- again * Update models/issue_assignees.go Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * CI.restart() * Update issue_assignees.go * add Test for GetUserIDsByNames * add Test for MakeIDsFromAPIAssigneesToAdd * fix test
Diffstat (limited to 'models/issue_assignees.go')
-rw-r--r--models/issue_assignees.go25
1 files changed, 11 insertions, 14 deletions
diff --git a/models/issue_assignees.go b/models/issue_assignees.go
index e15b718eb2..70bed039c2 100644
--- a/models/issue_assignees.go
+++ b/models/issue_assignees.go
@@ -7,6 +7,8 @@ package models
import (
"fmt"
+ "code.gitea.io/gitea/modules/util"
+
"xorm.io/xorm"
)
@@ -171,25 +173,20 @@ func toggleUserAssignee(e *xorm.Session, issue *Issue, assigneeID int64) (remove
// MakeIDsFromAPIAssigneesToAdd returns an array with all assignee IDs
func MakeIDsFromAPIAssigneesToAdd(oneAssignee string, multipleAssignees []string) (assigneeIDs []int64, err error) {
+ var requestAssignees []string
+
// Keeping the old assigning method for compatibility reasons
- if oneAssignee != "" {
-
- // Prevent double adding assignees
- var isDouble bool
- for _, assignee := range multipleAssignees {
- if assignee == oneAssignee {
- isDouble = true
- break
- }
- }
+ if oneAssignee != "" && !util.IsStringInSlice(oneAssignee, multipleAssignees) {
+ requestAssignees = append(requestAssignees, oneAssignee)
+ }
- if !isDouble {
- multipleAssignees = append(multipleAssignees, oneAssignee)
- }
+ //Prevent empty assignees
+ if len(multipleAssignees) > 0 && multipleAssignees[0] != "" {
+ requestAssignees = append(requestAssignees, multipleAssignees...)
}
// Get the IDs of all assignees
- assigneeIDs, err = GetUserIDsByNames(multipleAssignees, false)
+ assigneeIDs, err = GetUserIDsByNames(requestAssignees, false)
return
}