Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
keep sure if assigneeIDs == nil -> do nothing
Browse files Browse the repository at this point in the history
6543 committed Nov 7, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 1f90147 commit e72d941
Showing 2 changed files with 36 additions and 31 deletions.
34 changes: 18 additions & 16 deletions routers/api/v1/repo/issue.go
Original file line number Diff line number Diff line change
@@ -344,22 +344,24 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
return
}

// Check if the passed assignees is assignable
for _, aID := range assigneeIDs {
assignee, err := models.GetUserByID(aID)
if err != nil {
ctx.Error(500, "GetUserByID", err)
return
}

valid, err := models.CanBeAssigned(assignee, ctx.Repo.Repository, false)
if err != nil {
ctx.Error(500, "canBeAssigned", err)
return
}
if !valid {
ctx.Error(422, "canBeAssigned", models.ErrUserDoesNotHaveAccessToRepo{UserID: aID, RepoName: ctx.Repo.Repository.Name})
return
if assigneeIDs != nil {
for _, aID := range assigneeIDs {
assignee, err := models.GetUserByID(aID)
if err != nil {
ctx.Error(500, "GetUserByID", err)
return
}

// Check if the passed assignees is assignable
valid, err := models.CanBeAssigned(assignee, ctx.Repo.Repository, false)
if err != nil {
ctx.Error(500, "canBeAssigned", err)
return
}
if !valid {
ctx.Error(422, "canBeAssigned", models.ErrUserDoesNotHaveAccessToRepo{UserID: aID, RepoName: ctx.Repo.Repository.Name})
return
}
}
}
} else {
33 changes: 18 additions & 15 deletions routers/api/v1/repo/pull.go
Original file line number Diff line number Diff line change
@@ -286,22 +286,25 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption
}
return
}
// Check if the passed assignees is assignable
for _, aID := range assigneeIDs {
assignee, err := models.GetUserByID(aID)
if err != nil {
ctx.Error(500, "GetUserByID", err)
return
}

valid, err := models.CanBeAssigned(assignee, repo, true)
if err != nil {
ctx.Error(500, "canBeAssigned", err)
return
}
if !valid {
ctx.Error(422, "canBeAssigned", models.ErrUserDoesNotHaveAccessToRepo{UserID: aID, RepoName: repo.Name})
return
if assigneeIDs != nil {
for _, aID := range assigneeIDs {
assignee, err := models.GetUserByID(aID)
if err != nil {
ctx.Error(500, "GetUserByID", err)
return
}

// Check if the passed assignees is assignable
valid, err := models.CanBeAssigned(assignee, repo, true)
if err != nil {
ctx.Error(500, "canBeAssigned", err)
return
}
if !valid {
ctx.Error(422, "canBeAssigned", models.ErrUserDoesNotHaveAccessToRepo{UserID: aID, RepoName: repo.Name})
return
}
}
}

0 comments on commit e72d941

Please sign in to comment.