From f823be5fc81dabadd8f15dccd7a81d3c4a70f453 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Fri, 16 Dec 2022 14:52:04 +0100 Subject: [PATCH 1/3] Allow empty assignees. --- routers/api/v1/repo/pull.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 1246ede9e6d7a..f8eb76294ded0 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -527,7 +527,7 @@ func EditPullRequest(ctx *context.APIContext) { // Pass one or more user logins to replace the set of assignees on this Issue. // Send an empty array ([]) to clear all assignees from the Issue. - if ctx.Repo.CanWrite(unit.TypePullRequests) && (form.Assignees != nil || len(form.Assignee) > 0) { + if ctx.Repo.CanWrite(unit.TypePullRequests) { err = issue_service.UpdateAssignees(issue, form.Assignee, form.Assignees, ctx.Doer) if err != nil { if user_model.IsErrUserNotExist(err) { From 3bbd08ce72d0032a4fc2b877e8d9f82aa54a0446 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Sat, 17 Dec 2022 14:55:47 +0100 Subject: [PATCH 2/3] Load issue attributes. --- routers/api/v1/repo/pull.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index f8eb76294ded0..4c139fb1326b0 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -489,6 +489,11 @@ func EditPullRequest(ctx *context.APIContext) { } issue := pr.Issue issue.Repo = ctx.Repo.Repository + + if err := issue.LoadAttributes(ctx); err != nil { + ctx.Error(http.StatusInternalServerError, "LoadAttributes", err) + return + } if !issue.IsPoster(ctx.Doer.ID) && !ctx.Repo.CanWrite(unit.TypePullRequests) { ctx.Status(http.StatusForbidden) @@ -527,7 +532,7 @@ func EditPullRequest(ctx *context.APIContext) { // Pass one or more user logins to replace the set of assignees on this Issue. // Send an empty array ([]) to clear all assignees from the Issue. - if ctx.Repo.CanWrite(unit.TypePullRequests) { + if ctx.Repo.CanWrite(unit.TypePullRequests) && (form.Assignees != nil || len(form.Assignee) > 0) { err = issue_service.UpdateAssignees(issue, form.Assignee, form.Assignees, ctx.Doer) if err != nil { if user_model.IsErrUserNotExist(err) { From 1c01fff2b1e56cda9757497163633b76e1a39916 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Sat, 17 Dec 2022 14:16:57 +0000 Subject: [PATCH 3/3] lint --- routers/api/v1/repo/pull.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 4c139fb1326b0..ed23b267f2871 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -489,7 +489,7 @@ func EditPullRequest(ctx *context.APIContext) { } issue := pr.Issue issue.Repo = ctx.Repo.Repository - + if err := issue.LoadAttributes(ctx); err != nil { ctx.Error(http.StatusInternalServerError, "LoadAttributes", err) return