@@ -207,6 +207,10 @@ func ListIssues(ctx *context.APIContext) {
207
207
// in: query
208
208
// description: search string
209
209
// type: string
210
+ // - name: type
211
+ // in: query
212
+ // description: filter by type (issues / pulls) if set
213
+ // type: string
210
214
// responses:
211
215
// "200":
212
216
// "$ref": "#/responses/IssueList"
@@ -242,6 +246,16 @@ func ListIssues(ctx *context.APIContext) {
242
246
}
243
247
}
244
248
249
+ var isPull util.OptionalBool
250
+ switch ctx .Query ("type" ) {
251
+ case "pulls" :
252
+ isPull = util .OptionalBoolTrue
253
+ case "issues" :
254
+ isPull = util .OptionalBoolFalse
255
+ default :
256
+ isPull = util .OptionalBoolNone
257
+ }
258
+
245
259
// Only fetch the issues if we either don't have a keyword or the search returned issues
246
260
// This would otherwise return all issues if no issues were found by the search.
247
261
if len (keyword ) == 0 || len (issueIDs ) > 0 || len (labelIDs ) > 0 {
@@ -252,6 +266,7 @@ func ListIssues(ctx *context.APIContext) {
252
266
IsClosed : isClosed ,
253
267
IssueIDs : issueIDs ,
254
268
LabelIDs : labelIDs ,
269
+ IsPull : isPull ,
255
270
})
256
271
}
257
272
@@ -476,14 +491,15 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
476
491
return
477
492
}
478
493
issue .Repo = ctx .Repo .Repository
494
+ canWrite := ctx .Repo .CanWriteIssuesOrPulls (issue .IsPull )
479
495
480
496
err = issue .LoadAttributes ()
481
497
if err != nil {
482
498
ctx .Error (http .StatusInternalServerError , "LoadAttributes" , err )
483
499
return
484
500
}
485
501
486
- if ! issue .IsPoster (ctx .User .ID ) && ! ctx . Repo . CanWrite ( models . UnitTypeIssues ) {
502
+ if ! issue .IsPoster (ctx .User .ID ) && ! canWrite {
487
503
ctx .Status (http .StatusForbidden )
488
504
return
489
505
}
@@ -496,7 +512,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
496
512
}
497
513
498
514
// Update or remove the deadline, only if set and allowed
499
- if (form .Deadline != nil || form .RemoveDeadline != nil ) && ctx . Repo . CanWrite ( models . UnitTypeIssues ) {
515
+ if (form .Deadline != nil || form .RemoveDeadline != nil ) && canWrite {
500
516
var deadlineUnix timeutil.TimeStamp
501
517
502
518
if (form .RemoveDeadline == nil || ! * form .RemoveDeadline ) && ! form .Deadline .IsZero () {
@@ -520,7 +536,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
520
536
// Pass one or more user logins to replace the set of assignees on this Issue.
521
537
// Send an empty array ([]) to clear all assignees from the Issue.
522
538
523
- if ctx . Repo . CanWrite ( models . UnitTypeIssues ) && (form .Assignees != nil || form .Assignee != nil ) {
539
+ if canWrite && (form .Assignees != nil || form .Assignee != nil ) {
524
540
oneAssignee := ""
525
541
if form .Assignee != nil {
526
542
oneAssignee = * form .Assignee
@@ -533,7 +549,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
533
549
}
534
550
}
535
551
536
- if ctx . Repo . CanWrite ( models . UnitTypeIssues ) && form .Milestone != nil &&
552
+ if canWrite && form .Milestone != nil &&
537
553
issue .MilestoneID != * form .Milestone {
538
554
oldMilestoneID := issue .MilestoneID
539
555
issue .MilestoneID = * form .Milestone
@@ -619,7 +635,7 @@ func UpdateIssueDeadline(ctx *context.APIContext, form api.EditDeadlineOption) {
619
635
return
620
636
}
621
637
622
- if ! ctx .Repo .CanWrite ( models . UnitTypeIssues ) {
638
+ if ! ctx .Repo .CanWriteIssuesOrPulls ( issue . IsPull ) {
623
639
ctx .Error (http .StatusForbidden , "" , "Not repo writer" )
624
640
return
625
641
}
0 commit comments