]> source.dussan.org Git - gitea.git/commitdiff
issues api allow pulls and fix #4832 (#4852) (#4862)
authorLunny Xiao <xiaolunwen@gmail.com>
Wed, 5 Sep 2018 02:13:56 +0000 (10:13 +0800)
committertechknowlogick <techknowlogick@users.noreply.github.com>
Wed, 5 Sep 2018 02:13:56 +0000 (22:13 -0400)
routers/api/v1/api.go

index 5007a0d56d10abdbc260f732266ccc9666a2144a..1029477ab917a977cf964e2ae7a52f7138f98f23 100644 (file)
@@ -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)