Skip to content

Commit 3139ccf

Browse files
committed
1 parent e72d941 commit 3139ccf

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

models/issue_assignees.go

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,25 +171,34 @@ func toggleUserAssignee(e *xorm.Session, issue *Issue, assigneeID int64) (remove
171171
// MakeIDsFromAPIAssigneesToAdd returns an array with all assignee IDs
172172
func MakeIDsFromAPIAssigneesToAdd(oneAssignee string, multipleAssignees []string) (assigneeIDs []int64, err error) {
173173

174-
// Keeping the old assigning method for compatibility reasons
175-
if oneAssignee != "" {
176-
177-
// Prevent double adding assignees
178-
var isDouble bool
179-
for _, assignee := range multipleAssignees {
180-
if assignee == oneAssignee {
181-
isDouble = true
182-
break
183-
}
174+
var requestAssignees []string
175+
176+
// Prevent double adding assignees and empty assignees
177+
var isDouble bool
178+
for _, assignee := range multipleAssignees {
179+
// Keeping the old assigning method for compatibility reasons
180+
if assignee == oneAssignee {
181+
isDouble = true
182+
continue
184183
}
185184

186-
if !isDouble {
187-
multipleAssignees = append(multipleAssignees, oneAssignee)
185+
//if assignee is empty skip
186+
if len(assignee) == 0 {
187+
continue
188188
}
189+
requestAssignees = append(requestAssignees, assignee)
189190
}
190191

191-
// Get the IDs of all assignees
192-
assigneeIDs, err = GetUserIDsByNames(multipleAssignees, false)
192+
if !isDouble {
193+
requestAssignees = append(requestAssignees, oneAssignee)
194+
}
195+
196+
if len(requestAssignees) > 0 {
197+
// Get the IDs of all assignees
198+
assigneeIDs, err = GetUserIDsByNames(requestAssignees, false)
199+
} else {
200+
return nil, nil
201+
}
193202

194203
return
195204
}

0 commit comments

Comments
 (0)