diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2020-12-10 01:20:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-09 17:20:13 +0000 |
commit | 6edfa6bc88ed73fc5a31f1b2fe9f5587c932ada7 (patch) | |
tree | e6c479d97cbd006c3cc521ec77fde5c0d72b4cc1 /routers | |
parent | 18e4477ad41a8733225d3c92eea5b91c12af1a94 (diff) | |
download | gitea-6edfa6bc88ed73fc5a31f1b2fe9f5587c932ada7.tar.gz gitea-6edfa6bc88ed73fc5a31f1b2fe9f5587c932ada7.zip |
Fix broken migration on webhook (#13911)
* Fix broken migration on webhook
* Fix lint
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/utils/hook.go | 8 | ||||
-rw-r--r-- | routers/repo/webhook.go | 22 |
2 files changed, 15 insertions, 15 deletions
diff --git a/routers/api/v1/utils/hook.go b/routers/api/v1/utils/hook.go index 85af6c8e6a..c8471184f5 100644 --- a/routers/api/v1/utils/hook.go +++ b/routers/api/v1/utils/hook.go @@ -132,10 +132,10 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, orgID, repoID }, BranchFilter: form.BranchFilter, }, - IsActive: form.Active, - HookTaskType: models.HookTaskType(form.Type), + IsActive: form.Active, + Type: models.HookTaskType(form.Type), } - if w.HookTaskType == models.SLACK { + if w.Type == models.SLACK { channel, ok := form.Config["channel"] if !ok { ctx.Error(http.StatusUnprocessableEntity, "", "Missing config option: channel") @@ -219,7 +219,7 @@ func editHook(ctx *context.APIContext, form *api.EditHookOption, w *models.Webho w.ContentType = models.ToHookContentType(ct) } - if w.HookTaskType == models.SLACK { + if w.Type == models.SLACK { if channel, ok := form.Config["channel"]; ok { meta, err := json.Marshal(&webhook.SlackMeta{ Channel: channel, diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go index 15d2db88c5..49aec8184b 100644 --- a/routers/repo/webhook.go +++ b/routers/repo/webhook.go @@ -208,7 +208,7 @@ func GiteaHooksNewPost(ctx *context.Context, form auth.NewWebhookForm) { Secret: form.Secret, HookEvent: ParseHookEvent(form.WebhookForm), IsActive: form.Active, - HookTaskType: models.GITEA, + Type: models.GITEA, OrgID: orCtx.OrgID, IsSystemWebhook: orCtx.IsSystemWebhook, } @@ -261,7 +261,7 @@ func newGogsWebhookPost(ctx *context.Context, form auth.NewGogshookForm, kind mo Secret: form.Secret, HookEvent: ParseHookEvent(form.WebhookForm), IsActive: form.Active, - HookTaskType: kind, + Type: kind, OrgID: orCtx.OrgID, IsSystemWebhook: orCtx.IsSystemWebhook, } @@ -311,7 +311,7 @@ func DiscordHooksNewPost(ctx *context.Context, form auth.NewDiscordHookForm) { ContentType: models.ContentTypeJSON, HookEvent: ParseHookEvent(form.WebhookForm), IsActive: form.Active, - HookTaskType: models.DISCORD, + Type: models.DISCORD, Meta: string(meta), OrgID: orCtx.OrgID, IsSystemWebhook: orCtx.IsSystemWebhook, @@ -353,7 +353,7 @@ func DingtalkHooksNewPost(ctx *context.Context, form auth.NewDingtalkHookForm) { ContentType: models.ContentTypeJSON, HookEvent: ParseHookEvent(form.WebhookForm), IsActive: form.Active, - HookTaskType: models.DINGTALK, + Type: models.DINGTALK, Meta: "", OrgID: orCtx.OrgID, IsSystemWebhook: orCtx.IsSystemWebhook, @@ -404,7 +404,7 @@ func TelegramHooksNewPost(ctx *context.Context, form auth.NewTelegramHookForm) { ContentType: models.ContentTypeJSON, HookEvent: ParseHookEvent(form.WebhookForm), IsActive: form.Active, - HookTaskType: models.TELEGRAM, + Type: models.TELEGRAM, Meta: string(meta), OrgID: orCtx.OrgID, IsSystemWebhook: orCtx.IsSystemWebhook, @@ -458,7 +458,7 @@ func MatrixHooksNewPost(ctx *context.Context, form auth.NewMatrixHookForm) { HTTPMethod: "PUT", HookEvent: ParseHookEvent(form.WebhookForm), IsActive: form.Active, - HookTaskType: models.MATRIX, + Type: models.MATRIX, Meta: string(meta), OrgID: orCtx.OrgID, IsSystemWebhook: orCtx.IsSystemWebhook, @@ -500,7 +500,7 @@ func MSTeamsHooksNewPost(ctx *context.Context, form auth.NewMSTeamsHookForm) { ContentType: models.ContentTypeJSON, HookEvent: ParseHookEvent(form.WebhookForm), IsActive: form.Active, - HookTaskType: models.MSTEAMS, + Type: models.MSTEAMS, Meta: "", OrgID: orCtx.OrgID, IsSystemWebhook: orCtx.IsSystemWebhook, @@ -559,7 +559,7 @@ func SlackHooksNewPost(ctx *context.Context, form auth.NewSlackHookForm) { ContentType: models.ContentTypeJSON, HookEvent: ParseHookEvent(form.WebhookForm), IsActive: form.Active, - HookTaskType: models.SLACK, + Type: models.SLACK, Meta: string(meta), OrgID: orCtx.OrgID, IsSystemWebhook: orCtx.IsSystemWebhook, @@ -601,7 +601,7 @@ func FeishuHooksNewPost(ctx *context.Context, form auth.NewFeishuHookForm) { ContentType: models.ContentTypeJSON, HookEvent: ParseHookEvent(form.WebhookForm), IsActive: form.Active, - HookTaskType: models.FEISHU, + Type: models.FEISHU, Meta: "", OrgID: orCtx.OrgID, IsSystemWebhook: orCtx.IsSystemWebhook, @@ -647,8 +647,8 @@ func checkWebhook(ctx *context.Context) (*orgRepoCtx, *models.Webhook) { return nil, nil } - ctx.Data["HookType"] = w.HookTaskType - switch w.HookTaskType { + ctx.Data["HookType"] = w.Type + switch w.Type { case models.SLACK: ctx.Data["SlackHook"] = webhook.GetSlackHook(w) case models.DISCORD: |