-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Allow creating and editing system webhooks. #23142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
66c356c
f2f1bbf
d9f7774
a85c3ba
5bc1f88
040cb8b
5384c1d
2cadf91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,6 +24,7 @@ type Hook struct { | |||||||||||||||||||||||||
| Events []string `json:"events"` | ||||||||||||||||||||||||||
| AuthorizationHeader string `json:"authorization_header"` | ||||||||||||||||||||||||||
| Active bool `json:"active"` | ||||||||||||||||||||||||||
| IsSystemWebhook bool `json:"is_system_webhook"` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| m.Group("/{hookType:system-hooks|default-hooks}", func() { | |
| m.Combo("").Get(admin.ListHooks). | |
| Post(bind(api.CreateHookOption{}), admin.CreateHook) | |
| m.Combo("/{id}").Get(admin.GetHook). | |
| Patch(bind(api.EditHookOption{}), admin.EditHook). | |
| Delete(admin.DeleteHook) | |
| }) |
gitea/routers/api/v1/admin/hooks.go
Line 24 in 5384c1d
| // swagger:operation GET /admin/{hookType} admin adminListHooks |
gitea/routers/api/v1/admin/hooks.go
Line 62 in 5384c1d
| // swagger:operation GET /admin/{hookType}/{id} admin adminGetHook |
gitea/routers/api/v1/admin/hooks.go
Line 107 in 5384c1d
| // swagger:operation POST /admin/{hookType} admin adminCreateHook |
gitea/routers/api/v1/admin/hooks.go
Line 139 in 5384c1d
| // swagger:operation PATCH /admin/{hookType}/{id} admin adminEditHook |
gitea/routers/api/v1/admin/hooks.go
Line 178 in 5384c1d
| // swagger:operation DELETE /admin/{hookType}/{id} admin adminDeleteHook |
Doing this ballooned the PR, but it makes the API more friendly:
and it also matches how the admin web UI works, where the two links on /admin/system-hooks/
go to /admin/system-hooks/{kind}/new and http://localhost:3000/admin/default-hooks/{kind}/new respectively.
What do you think?
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ func ListHooks(ctx *context.APIContext) { | |
| // "200": | ||
| // "$ref": "#/responses/HookList" | ||
|
|
||
| sysHooks, err := webhook.GetSystemWebhooks(ctx, util.OptionalBoolNone) | ||
| sysHooks, err := webhook.GetSystemOrDefaultWebhooks(ctx, util.OptionalBoolNone) | ||
|
||
| if err != nil { | ||
| ctx.Error(http.StatusInternalServerError, "GetSystemWebhooks", err) | ||
| return | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's improvements to be made here. For example, if this exists, do we really still need
GetSystemWebhooks()? Would you ever use both?