Add more webhooks support and refactor webhook templates directory (#3929)
* add more webhook support * move hooks templates to standalone dir and add more webhooks ui * fix tests * update vendor checksum * add more webhook support * move hooks templates to standalone dir and add more webhooks ui * fix tests * update vendor checksum * update vendor Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * load attributes when created release * update comparsion doc
This commit is contained in:
parent
188fe6c301
commit
24941a1046
33 changed files with 1010 additions and 118 deletions
|
@ -7,12 +7,13 @@ package utils
|
|||
import (
|
||||
api "code.gitea.io/sdk/gitea"
|
||||
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/routers/api/v1/convert"
|
||||
"encoding/json"
|
||||
"github.com/Unknwon/com"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// GetOrgHook get an organization's webhook. If there is an error, write to
|
||||
|
@ -98,9 +99,15 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, orgID, repoID
|
|||
HookEvent: &models.HookEvent{
|
||||
ChooseEvents: true,
|
||||
HookEvents: models.HookEvents{
|
||||
Create: com.IsSliceContainsStr(form.Events, string(models.HookEventCreate)),
|
||||
Push: com.IsSliceContainsStr(form.Events, string(models.HookEventPush)),
|
||||
PullRequest: com.IsSliceContainsStr(form.Events, string(models.HookEventPullRequest)),
|
||||
Create: com.IsSliceContainsStr(form.Events, string(models.HookEventCreate)),
|
||||
Delete: com.IsSliceContainsStr(form.Events, string(models.HookEventDelete)),
|
||||
Fork: com.IsSliceContainsStr(form.Events, string(models.HookEventFork)),
|
||||
Issues: com.IsSliceContainsStr(form.Events, string(models.HookEventIssues)),
|
||||
IssueComment: com.IsSliceContainsStr(form.Events, string(models.HookEventIssueComment)),
|
||||
Push: com.IsSliceContainsStr(form.Events, string(models.HookEventPush)),
|
||||
PullRequest: com.IsSliceContainsStr(form.Events, string(models.HookEventPullRequest)),
|
||||
Repository: com.IsSliceContainsStr(form.Events, string(models.HookEventRepository)),
|
||||
Release: com.IsSliceContainsStr(form.Events, string(models.HookEventRelease)),
|
||||
},
|
||||
},
|
||||
IsActive: form.Active,
|
||||
|
@ -211,6 +218,16 @@ func editHook(ctx *context.APIContext, form *api.EditHookOption, w *models.Webho
|
|||
w.Create = com.IsSliceContainsStr(form.Events, string(models.HookEventCreate))
|
||||
w.Push = com.IsSliceContainsStr(form.Events, string(models.HookEventPush))
|
||||
w.PullRequest = com.IsSliceContainsStr(form.Events, string(models.HookEventPullRequest))
|
||||
w.Create = com.IsSliceContainsStr(form.Events, string(models.HookEventCreate))
|
||||
w.Delete = com.IsSliceContainsStr(form.Events, string(models.HookEventDelete))
|
||||
w.Fork = com.IsSliceContainsStr(form.Events, string(models.HookEventFork))
|
||||
w.Issues = com.IsSliceContainsStr(form.Events, string(models.HookEventIssues))
|
||||
w.IssueComment = com.IsSliceContainsStr(form.Events, string(models.HookEventIssueComment))
|
||||
w.Push = com.IsSliceContainsStr(form.Events, string(models.HookEventPush))
|
||||
w.PullRequest = com.IsSliceContainsStr(form.Events, string(models.HookEventPullRequest))
|
||||
w.Repository = com.IsSliceContainsStr(form.Events, string(models.HookEventRepository))
|
||||
w.Release = com.IsSliceContainsStr(form.Events, string(models.HookEventRelease))
|
||||
|
||||
if err := w.UpdateEvent(); err != nil {
|
||||
ctx.Error(500, "UpdateEvent", err)
|
||||
return false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue