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