Skip to content

Commit 1901f35

Browse files
lunnytechknowlogick
authored andcommitted
issues api allow pulls and fix #4832 (#4852) (#4862)
1 parent 745c898 commit 1901f35

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

routers/api/v1/api.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,14 @@ func mustAllowPulls(ctx *context.Context) {
273273
}
274274
}
275275

276+
func mustEnableIssuesOrPulls(ctx *context.Context) {
277+
if !ctx.Repo.Repository.UnitEnabled(models.UnitTypeIssues) &&
278+
!ctx.Repo.Repository.AllowsPulls() {
279+
ctx.Status(404)
280+
return
281+
}
282+
}
283+
276284
// RegisterRoutes registers all v1 APIs routes to web application.
277285
// FIXME: custom form error response
278286
func RegisterRoutes(m *macaron.Macaron) {
@@ -447,7 +455,7 @@ func RegisterRoutes(m *macaron.Macaron) {
447455
Post(reqToken(), bind(api.AddTimeOption{}), repo.AddTime)
448456
})
449457
})
450-
}, mustEnableIssues)
458+
}, mustEnableIssuesOrPulls)
451459
m.Group("/labels", func() {
452460
m.Combo("").Get(repo.ListLabels).
453461
Post(reqToken(), bind(api.CreateLabelOption{}), repo.CreateLabel)

0 commit comments

Comments
 (0)