diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2018-05-16 22:01:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-16 22:01:55 +0800 |
commit | 24941a10464dc27eaebafda2a208fa827b74ff8d (patch) | |
tree | c875dd6b7d659e2dbd926dbd3a04a036f9f41c94 /routers | |
parent | 188fe6c301f9c44d569b75cb339d6a6b3f6e03ad (diff) | |
download | gitea-24941a10464dc27eaebafda2a208fa827b74ff8d.tar.gz gitea-24941a10464dc27eaebafda2a208fa827b74ff8d.zip |
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
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/issue_comment.go | 5 | ||||
-rw-r--r-- | routers/api/v1/utils/hook.go | 27 | ||||
-rw-r--r-- | routers/repo/issue.go | 5 | ||||
-rw-r--r-- | routers/repo/webhook.go | 19 |
4 files changed, 40 insertions, 16 deletions
diff --git a/routers/api/v1/repo/issue_comment.go b/routers/api/v1/repo/issue_comment.go index a9258849ea..2865ea9165 100644 --- a/routers/api/v1/repo/issue_comment.go +++ b/routers/api/v1/repo/issue_comment.go @@ -261,8 +261,9 @@ func editIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) return } + oldContent := comment.Content comment.Content = form.Body - if err := models.UpdateComment(comment); err != nil { + if err := models.UpdateComment(ctx.User, comment, oldContent); err != nil { ctx.Error(500, "UpdateComment", err) return } @@ -348,7 +349,7 @@ func deleteIssueComment(ctx *context.APIContext) { return } - if err = models.DeleteComment(comment); err != nil { + if err = models.DeleteComment(ctx.User, comment); err != nil { ctx.Error(500, "DeleteCommentByID", err) return } diff --git a/routers/api/v1/utils/hook.go b/routers/api/v1/utils/hook.go index e1533da94c..d0538ec54f 100644 --- a/routers/api/v1/utils/hook.go +++ b/routers/api/v1/utils/hook.go @@ -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 diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 33ba3e0d64..18ab1691cd 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -1086,6 +1086,7 @@ func UpdateCommentContent(ctx *context.Context) { return } + oldContent := comment.Content comment.Content = ctx.Query("content") if len(comment.Content) == 0 { ctx.JSON(200, map[string]interface{}{ @@ -1093,7 +1094,7 @@ func UpdateCommentContent(ctx *context.Context) { }) return } - if err = models.UpdateComment(comment); err != nil { + if err = models.UpdateComment(ctx.User, comment, oldContent); err != nil { ctx.ServerError("UpdateComment", err) return } @@ -1119,7 +1120,7 @@ func DeleteComment(ctx *context.Context) { return } - if err = models.DeleteComment(comment); err != nil { + if err = models.DeleteComment(ctx.User, comment); err != nil { ctx.ServerError("DeleteCommentByID", err) return } diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go index 35fdf796b5..6994aa3344 100644 --- a/routers/repo/webhook.go +++ b/routers/repo/webhook.go @@ -23,9 +23,9 @@ import ( ) const ( - tplHooks base.TplName = "repo/settings/hooks" - tplHookNew base.TplName = "repo/settings/hook_new" - tplOrgHookNew base.TplName = "org/settings/hook_new" + tplHooks base.TplName = "repo/settings/webhook/base" + tplHookNew base.TplName = "repo/settings/webhook/new" + tplOrgHookNew base.TplName = "org/settings/webhook/new" ) // Webhooks render web hooks list page @@ -118,10 +118,15 @@ func ParseHookEvent(form auth.WebhookForm) *models.HookEvent { SendEverything: form.SendEverything(), ChooseEvents: form.ChooseEvents(), HookEvents: models.HookEvents{ - Create: form.Create, - Push: form.Push, - PullRequest: form.PullRequest, - Repository: form.Repository, + Create: form.Create, + Delete: form.Delete, + Fork: form.Fork, + Issues: form.Issues, + IssueComment: form.IssueComment, + Release: form.Release, + Push: form.Push, + PullRequest: form.PullRequest, + Repository: form.Repository, }, } } |