diff options
author | Unknwon <u@gogs.io> | 2016-07-16 01:02:55 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-07-16 01:02:55 +0800 |
commit | 3d93532c87823159dd03e9c64a58c7bafed0fa64 (patch) | |
tree | cdf287400fd753711138486ce06766b3c789d96a /routers | |
parent | fff615d5fc257c812f197a801578f32c177fbef9 (diff) |
#3274 fix can't get webhook detail of organization
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/hook.go | 2 | ||||
-rw-r--r-- | routers/org/setting.go | 2 | ||||
-rw-r--r-- | routers/repo/webhook.go | 7 |
3 files changed, 8 insertions, 3 deletions
diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go index 0dac8f7c..0bf46977 100644 --- a/routers/api/v1/repo/hook.go +++ b/routers/api/v1/repo/hook.go @@ -98,7 +98,7 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) { // https://github.com/gogits/go-gogs-client/wiki/Repositories#edit-a-hook func EditHook(ctx *context.APIContext, form api.EditHookOption) { - w, err := models.GetWebhookByID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) + w, err := models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) if err != nil { if models.IsErrWebhookNotExist(err) { ctx.Status(404) diff --git a/routers/org/setting.go b/routers/org/setting.go index c50e18d7..a938581c 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -154,7 +154,7 @@ func Webhooks(ctx *context.Context) { return } - ws, err := models.GetWebhooksByOrgId(ctx.Org.Organization.Id) + ws, err := models.GetWebhooksByOrgID(ctx.Org.Organization.Id) if err != nil { ctx.Handle(500, "GetWebhooksByOrgId", err) return diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go index d9048623..b2274033 100644 --- a/routers/repo/webhook.go +++ b/routers/repo/webhook.go @@ -220,7 +220,12 @@ func checkWebhook(ctx *context.Context) (*OrgRepoCtx, *models.Webhook) { } ctx.Data["BaseLink"] = orCtx.Link - w, err := models.GetWebhookByID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) + var w *models.Webhook + if orCtx.RepoID > 0 { + w, err = models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) + } else { + w, err = models.GetWebhookByOrgID(ctx.Org.Organization.Id, ctx.ParamsInt64(":id")) + } if err != nil { if models.IsErrWebhookNotExist(err) { ctx.Handle(404, "GetWebhookByID", nil) |