-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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"` | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although the database stored as the name, but maybe we can have a better name like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've gotten around to this again finally. I decided to replace Lines 1384 to 1390 in 5384c1d
gitea/routers/api/v1/admin/hooks.go Line 24 in 5384c1d
gitea/routers/api/v1/admin/hooks.go Line 62 in 5384c1d
gitea/routers/api/v1/admin/hooks.go Line 107 in 5384c1d
gitea/routers/api/v1/admin/hooks.go Line 139 in 5384c1d
gitea/routers/api/v1/admin/hooks.go Line 178 in 5384c1d
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 go to What do you think? |
||||||||||||||||||||||||||
// swagger:strfmt date-time | ||||||||||||||||||||||||||
Updated time.Time `json:"updated_at"` | ||||||||||||||||||||||||||
// swagger:strfmt date-time | ||||||||||||||||||||||||||
|
@@ -48,7 +49,8 @@ type CreateHookOption struct { | |||||||||||||||||||||||||
BranchFilter string `json:"branch_filter" binding:"GlobPattern"` | ||||||||||||||||||||||||||
AuthorizationHeader string `json:"authorization_header"` | ||||||||||||||||||||||||||
// default: false | ||||||||||||||||||||||||||
Active bool `json:"active"` | ||||||||||||||||||||||||||
Active bool `json:"active"` | ||||||||||||||||||||||||||
IsSystemWebhook bool `json:"is_system_webhook"` | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// EditHookOption options when modify one hook | ||||||||||||||||||||||||||
|
@@ -57,6 +59,7 @@ type EditHookOption struct { | |||||||||||||||||||||||||
Events []string `json:"events"` | ||||||||||||||||||||||||||
BranchFilter string `json:"branch_filter" binding:"GlobPattern"` | ||||||||||||||||||||||||||
AuthorizationHeader string `json:"authorization_header"` | ||||||||||||||||||||||||||
IsSystemWebhook *bool `json:"is_system_webhook"` | ||||||||||||||||||||||||||
Active *bool `json:"active"` | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should change the behaviour? Maybe we should have parameter or we could have another endpoint for default webhooks? |
||
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?