From dfe6f5a317e9b3c5de67ec442eae2e7d920e10a9 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 4 Sep 2018 01:20:54 +0800 Subject: [PATCH] issues api allow pulls and fix #4832 (#4852) --- routers/api/v1/api.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 5007a0d56d10a..1029477ab917a 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -273,6 +273,14 @@ func mustAllowPulls(ctx *context.Context) { } } +func mustEnableIssuesOrPulls(ctx *context.Context) { + if !ctx.Repo.Repository.UnitEnabled(models.UnitTypeIssues) && + !ctx.Repo.Repository.AllowsPulls() { + ctx.Status(404) + return + } +} + // RegisterRoutes registers all v1 APIs routes to web application. // FIXME: custom form error response func RegisterRoutes(m *macaron.Macaron) { @@ -447,7 +455,7 @@ func RegisterRoutes(m *macaron.Macaron) { Post(reqToken(), bind(api.AddTimeOption{}), repo.AddTime) }) }) - }, mustEnableIssues) + }, mustEnableIssuesOrPulls) m.Group("/labels", func() { m.Combo("").Get(repo.ListLabels). Post(reqToken(), bind(api.CreateLabelOption{}), repo.CreateLabel)