func WebHooks(ctx *middleware.Context) { ctx.Data["IsRepoToolbarWebHooks"] = true ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Webhooks" // Delete webhook. remove, _ := base.StrTo(ctx.Query("remove")).Int64() if remove > 0 { if err := models.DeleteWebhook(remove); err != nil { ctx.Handle(500, "setting.WebHooks(DeleteWebhook)", err) return } ctx.Flash.Success("Webhook has been removed.") ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks") return } ws, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.Id) if err != nil { ctx.Handle(500, "setting.WebHooks(GetWebhooksByRepoId)", err) return } ctx.Data["Webhooks"] = ws ctx.HTML(200, "repo/hooks") }
func Webhooks(ctx *middleware.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings") ctx.Data["PageIsSettingsHooks"] = true // Delete web hook. remove := com.StrTo(ctx.Query("remove")).MustInt64() if remove > 0 { if err := models.DeleteWebhook(remove); err != nil { ctx.Handle(500, "DeleteWebhook", err) return } ctx.Flash.Success(ctx.Tr("repo.settings.remove_hook_success")) ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks") return } ws, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.Id) if err != nil { ctx.Handle(500, "GetWebhooksByRepoId", err) return } ctx.Data["Webhooks"] = ws ctx.HTML(200, HOOKS) }
// GET /repos/:username/:reponame/hooks // https://developer.github.com/v3/repos/hooks/#list-hooks func ListRepoHooks(ctx *middleware.Context) { hooks, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.Id) if err != nil { ctx.JSON(500, &base.ApiJsonErr{"GetWebhooksByRepoId: " + err.Error(), base.DOC_URL}) return } apiHooks := make([]*api.Hook, len(hooks)) for i := range hooks { h := &api.Hook{ Id: hooks[i].Id, Type: hooks[i].HookTaskType.Name(), Active: hooks[i].IsActive, Config: make(map[string]string), } // Currently, onle have push event. h.Events = []string{"push"} h.Config["url"] = hooks[i].Url h.Config["content_type"] = hooks[i].ContentType.Name() if hooks[i].HookTaskType == models.SLACK { s := hooks[i].GetSlackHook() h.Config["channel"] = s.Channel } apiHooks[i] = h } ctx.JSON(200, &apiHooks) }
// https://github.com/gogits/go-gogs-client/wiki/Repositories#list-hooks func ListRepoHooks(ctx *middleware.Context) { hooks, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.ID) if err != nil { ctx.APIError(500, "GetWebhooksByRepoId", err) return } apiHooks := make([]*api.Hook, len(hooks)) for i := range hooks { apiHooks[i] = ToApiHook(ctx.Repo.RepoLink, hooks[i]) } ctx.JSON(200, &apiHooks) }
// https://github.com/gogits/go-gogs-client/wiki/Repositories#list-hooks func ListRepoHooks(ctx *middleware.Context) { hooks, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.ID) if err != nil { ctx.JSON(500, &base.ApiJsonErr{"GetWebhooksByRepoId: " + err.Error(), base.DOC_URL}) return } apiHooks := make([]*api.Hook, len(hooks)) for i := range hooks { apiHooks[i] = ToApiHook(ctx.Repo.RepoLink, hooks[i]) } ctx.JSON(200, &apiHooks) }
func Webhooks(ctx *middleware.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings.hooks") ctx.Data["PageIsSettingsHooks"] = true ctx.Data["BaseLink"] = ctx.Repo.RepoLink ctx.Data["Description"] = ctx.Tr("repo.settings.hooks_desc", "https://github.com/gogits/go-gogs-client/wiki/Repositories---Webhooks") ws, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.ID) if err != nil { ctx.Handle(500, "GetWebhooksByRepoId", err) return } ctx.Data["Webhooks"] = ws ctx.HTML(200, HOOKS) }
func Webhooks(ctx *middleware.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings.hooks") ctx.Data["PageIsSettingsHooks"] = true ctx.Data["BaseLink"] = ctx.Repo.RepoLink ctx.Data["Description"] = ctx.Tr("repo.settings.hooks_desc", "http://gogs.io/docs/features/webhook.html") ws, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.ID) if err != nil { ctx.Handle(500, "GetWebhooksByRepoId", err) return } ctx.Data["Webhooks"] = ws ctx.HTML(200, HOOKS) }