Skip to content

Commit e72d941

Browse files
committed
keep sure if assigneeIDs == nil -> do nothing
1 parent 1f90147 commit e72d941

File tree

2 files changed

+36
-31
lines changed

2 files changed

+36
-31
lines changed

routers/api/v1/repo/issue.go

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -344,22 +344,24 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
344344
return
345345
}
346346

347-
// Check if the passed assignees is assignable
348-
for _, aID := range assigneeIDs {
349-
assignee, err := models.GetUserByID(aID)
350-
if err != nil {
351-
ctx.Error(500, "GetUserByID", err)
352-
return
353-
}
354-
355-
valid, err := models.CanBeAssigned(assignee, ctx.Repo.Repository, false)
356-
if err != nil {
357-
ctx.Error(500, "canBeAssigned", err)
358-
return
359-
}
360-
if !valid {
361-
ctx.Error(422, "canBeAssigned", models.ErrUserDoesNotHaveAccessToRepo{UserID: aID, RepoName: ctx.Repo.Repository.Name})
362-
return
347+
if assigneeIDs != nil {
348+
for _, aID := range assigneeIDs {
349+
assignee, err := models.GetUserByID(aID)
350+
if err != nil {
351+
ctx.Error(500, "GetUserByID", err)
352+
return
353+
}
354+
355+
// Check if the passed assignees is assignable
356+
valid, err := models.CanBeAssigned(assignee, ctx.Repo.Repository, false)
357+
if err != nil {
358+
ctx.Error(500, "canBeAssigned", err)
359+
return
360+
}
361+
if !valid {
362+
ctx.Error(422, "canBeAssigned", models.ErrUserDoesNotHaveAccessToRepo{UserID: aID, RepoName: ctx.Repo.Repository.Name})
363+
return
364+
}
363365
}
364366
}
365367
} else {

routers/api/v1/repo/pull.go

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -286,22 +286,25 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption
286286
}
287287
return
288288
}
289-
// Check if the passed assignees is assignable
290-
for _, aID := range assigneeIDs {
291-
assignee, err := models.GetUserByID(aID)
292-
if err != nil {
293-
ctx.Error(500, "GetUserByID", err)
294-
return
295-
}
296289

297-
valid, err := models.CanBeAssigned(assignee, repo, true)
298-
if err != nil {
299-
ctx.Error(500, "canBeAssigned", err)
300-
return
301-
}
302-
if !valid {
303-
ctx.Error(422, "canBeAssigned", models.ErrUserDoesNotHaveAccessToRepo{UserID: aID, RepoName: repo.Name})
304-
return
290+
if assigneeIDs != nil {
291+
for _, aID := range assigneeIDs {
292+
assignee, err := models.GetUserByID(aID)
293+
if err != nil {
294+
ctx.Error(500, "GetUserByID", err)
295+
return
296+
}
297+
298+
// Check if the passed assignees is assignable
299+
valid, err := models.CanBeAssigned(assignee, repo, true)
300+
if err != nil {
301+
ctx.Error(500, "canBeAssigned", err)
302+
return
303+
}
304+
if !valid {
305+
ctx.Error(422, "canBeAssigned", models.ErrUserDoesNotHaveAccessToRepo{UserID: aID, RepoName: repo.Name})
306+
return
307+
}
305308
}
306309
}
307310

0 commit comments

Comments
 (0)