diff options
Diffstat (limited to 'routers/api/v1/repo_hooks.go')
-rw-r--r-- | routers/api/v1/repo_hooks.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/routers/api/v1/repo_hooks.go b/routers/api/v1/repo_hooks.go index 49bf8e4679..5dddbc5a3d 100644 --- a/routers/api/v1/repo_hooks.go +++ b/routers/api/v1/repo_hooks.go @@ -107,9 +107,21 @@ func CreateRepoHook(ctx *middleware.Context, form CreateRepoHookForm) { return } - ctx.JSON(201, map[string]interface{}{ - "ok": true, - }) + apiHook := &api.Hook{ + Id: w.Id, + Type: w.HookTaskType.Name(), + Events: []string{"push"}, + Active: w.IsActive, + Config: map[string]string{ + "url": w.Url, + "content_type": w.ContentType.Name(), + }, + } + if w.HookTaskType == models.SLACK { + s := w.GetSlackHook() + apiHook.Config["channel"] = s.Channel + } + ctx.JSON(201, apiHook) } type EditRepoHookForm struct { |